Skip to content
Snippets Groups Projects
Commit cbf4165b authored by Felix's avatar Felix
Browse files

update draw networkx

parent f6971bcc
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# @Email: kramer@mpi-cbg.de # @Email: kramer@mpi-cbg.de
# @Project: go-with-the-flow # @Project: go-with-the-flow
# @Last modified by: Felix Kramer # @Last modified by: Felix Kramer
# @Last modified time: 2021-06-25T17:56:04+02:00 # @Last modified time: 2021-09-04T16:49:09+02:00
# @License: MIT # @License: MIT
import random as rd import random as rd
...@@ -43,10 +43,18 @@ def initialize_flow_circuit_from_random(random_type='default',periods=10,sidelen ...@@ -43,10 +43,18 @@ def initialize_flow_circuit_from_random(random_type='default',periods=10,sidelen
def setup_default_flow_circuit(dict_pars): def setup_default_flow_circuit(dict_pars):
kirchhoff_graph=initialize_flow_circuit_from_networkx(dict_pars['plexus']) kirchhoff_graph=initialize_flow_circuit_from_networkx(dict_pars['skeleton'])
kirchhoff_graph.set_source_landscape() kirchhoff_graph.set_source_landscape()
kirchhoff_graph.set_plexus_landscape() kirchhoff_graph.set_plexus_landscape()
return kirchhoff_graph
def setup_flow_circuit(dict_pars):
kirchhoff_graph=initialize_flow_circuit_from_networkx(dict_pars['skeleton'])
kirchhoff_graph.set_source_landscape(dict_pars['source'])
kirchhoff_graph.set_plexus_landscape(dict_pars['plexus'])
return kirchhoff_graph return kirchhoff_graph
# class flow_circuit(kirchhoff_init.circuit,object): # class flow_circuit(kirchhoff_init.circuit,object):
class flow_circuit(circuit,object): class flow_circuit(circuit,object):
...@@ -169,7 +177,7 @@ class flow_circuit(circuit,object): ...@@ -169,7 +177,7 @@ class flow_circuit(circuit,object):
pos=self.get_pos() pos=self.get_pos()
dist={} dist={}
for n,p in pos.items(): for n,p in pos.items():
dist[n]=np.linalg.norm(p) dist[n]=np.linalg.norm(p[0])
vals=list(dist.values()) vals=list(dist.values())
max_x=np.amax(vals) max_x=np.amax(vals)
...@@ -183,7 +191,7 @@ class flow_circuit(circuit,object): ...@@ -183,7 +191,7 @@ class flow_circuit(circuit,object):
elif v == min_x: elif v == min_x:
min_idx.append(k) min_idx.append(k)
self.set_poles_relationship(max_idx,min_idx) self.set_poles_relationship(max_idx,min_idx)
def init_source_dipole_point(self): def init_source_dipole_point(self):
...@@ -329,16 +337,20 @@ class flow_circuit(circuit,object): ...@@ -329,16 +337,20 @@ class flow_circuit(circuit,object):
return dn return dn
def get_edges_data(self): def get_edges_data(self,pars):
de=pd.DataFrame(self.edges[['conductivity','flow_rate']]) de=pd.DataFrame(self.edges[['conductivity','flow_rate']])
de['weight']=np.power(self.edges['conductivity'].to_numpy(),0.25)*self.draw_weight_scaling
if 'width' in pars:
de['weight']=np.absolute(self.edges[pars['width']].to_numpy())*self.draw_weight_scaling
else:
de['weight']=np.power(self.edges['conductivity'].to_numpy(),0.25)*self.draw_weight_scaling
return de return de
def plot_circuit(self): def plot_circuit(self,pars={}):
E=self.get_edges_data() E=self.get_edges_data(pars)
V=self.get_nodes_data() V=self.get_nodes_data()
self.set_pos() self.set_pos()
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# @Email: kramer@mpi-cbg.de # @Email: kramer@mpi-cbg.de
# @Project: go-with-the-flow # @Project: go-with-the-flow
# @Last modified by: Felix Kramer # @Last modified by: Felix Kramer
# @Last modified time: 2021-06-25T16:34:29+02:00 # @Last modified time: 2021-09-05T00:05:38+02:00
# @License: MIT # @License: MIT
# standard types # standard types
...@@ -186,7 +186,7 @@ def get_edge_invd_traces(input_graph,extra_data, **kwargs): ...@@ -186,7 +186,7 @@ def get_edge_invd_traces(input_graph,extra_data, **kwargs):
trace_list = [] trace_list = []
for i,edge in enumerate(E): for i,edge in enumerate(E):
options['weight']=5. options['weight']=5.
if 'weight' in extra_data: if 'weight' in extra_data:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# @Email: kramer@mpi-cbg.de # @Email: kramer@mpi-cbg.de
# @Project: go-with-the-flow # @Project: go-with-the-flow
# @Last modified by: Felix Kramer # @Last modified by: Felix Kramer
# @Last modified time: 2021-05-24T00:03:32+02:00 # @Last modified time: 2021-09-05T00:06:04+02:00
# @License: MIT # @License: MIT
import setuptools import setuptools
...@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh: ...@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup( setuptools.setup(
name="kirchhoff", # Replace with your own username name="kirchhoff", # Replace with your own username
version="0.1.3", version="0.1.4",
author="felixk1990", author="felixk1990",
author_email="felixuwekramer@protonmail.com", author_email="felixuwekramer@protonmail.com",
description="Collection of routines for creation and manipulation of Kirchhoff circuits based on resistor-only networks, together with 2D/3D spatial embeddings. ", description="Collection of routines for creation and manipulation of Kirchhoff circuits based on resistor-only networks, together with 2D/3D spatial embeddings. ",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment