diff --git a/d3graph/__init__.py b/d3graph/__init__.py index 75c4002..5e7d1fc 100644 --- a/d3graph/__init__.py +++ b/d3graph/__init__.py @@ -8,7 +8,7 @@ __author__ = 'Erdogan Tasksen' __email__ = 'erdogant@gmail.com' -__version__ = '2.0.3' +__version__ = '2.0.4' import jinja2 if version.parse(jinja2.__version__) > version.parse("2.11.3"): diff --git a/d3graph/d3graph.py b/d3graph/d3graph.py index 2976623..5c11d67 100644 --- a/d3graph/d3graph.py +++ b/d3graph/d3graph.py @@ -643,7 +643,8 @@ def edges2G(edge_properties, G=None): """ # Create new graph G if G is None: - G = nx.Graph() + # G = nx.Graph() + G = nx.DiGraph() edges = [*edge_properties] # Create edges in graph for edge in edges: @@ -670,7 +671,8 @@ def nodes2G(node_properties, G=None): """ # Create new graph G if G is None: - G = nx.Graph() + # G = nx.Graph() + G = nx.DiGraph() # Get node properties node_properties = pd.DataFrame(node_properties).T # Store node properties in Graph @@ -703,7 +705,8 @@ def make_graph(node_properties, edge_properties): """ # Create new Graph - G = nx.Graph() + # G = nx.Graph() + G = nx.DiGraph() # Add edges to graph G = edges2G(edge_properties, G=G) # Add nodes to graph diff --git a/d3graph/examples.py b/d3graph/examples.py index 81c9e82..05df413 100644 --- a/d3graph/examples.py +++ b/d3graph/examples.py @@ -5,6 +5,21 @@ from d3graph import d3graph +# %% Convert source-target to adjmat +from d3graph import d3graph, vec2adjmat +source = ['Penny', 'Penny', 'Amy', 'Bernadette', 'Bernadette', 'Sheldon', 'Sheldon', 'Sheldon', 'Rajesh'] +target = ['Leonard', 'Amy', 'Bernadette', 'Rajesh', 'Howard', 'Howard', 'Leonard', 'Amy', 'Penny'] +adjmat = vec2adjmat(source, target) +d3 = d3graph() +print(d3.config) + +d3.graph(adjmat) +# d3.show(showfig=True) + +d3.set_edge_properties(directed=False, edge_distance_minmax=[5, 30]) +d3.show(showfig=True) + + # %% from d3graph import d3graph d3 = d3graph() @@ -45,20 +60,22 @@ # %% Convert source-target to adjmat from d3graph import d3graph, vec2adjmat -source = ['Penny', 'Penny', 'Amy', 'Bernadette', 'Bernadette', 'Sheldon', 'Sheldon', 'Sheldon', 'Rajesh'] -target = ['Leonard', 'Amy', 'Bernadette', 'Rajesh', 'Howard', 'Howard', 'Leonard', 'Amy', 'Penny'] +source = ['Penny', 'Penny', 'Amy', 'Bernadette', 'Bernadette', 'Sheldon', 'Sheldon', 'Sheldon', 'Rajesh'] +target = ['Leonard', 'Amy', 'Bernadette', 'Rajesh', 'Howard', 'Howard', 'Leonard', 'Amy', 'Penny'] adjmat = vec2adjmat(source, target) d3 = d3graph() print(d3.config) -adjmat.iloc[0,0]=2 -adjmat.iloc[0,1]=3 -adjmat.iloc[0,2]=4 -adjmat.iloc[1,3]=12 +# adjmat.iloc[0,0]=2 +# adjmat.iloc[0,1]=3 +# adjmat.iloc[0,2]=4 +# adjmat.iloc[1,3]=12 d3.graph(adjmat) -d3.show(showfig=True) +# d3.show(showfig=True) +d3.set_edge_properties(directed=True, edge_distance_minmax=[5, 30]) +d3.show(showfig=True)