def Draw_Suspect_Fraud_Node (suspect, Anomalies_Subgraph): import d3py import networkx as nx import random Anomalies_Subgraph = nx.ego_graph(Anomalies_Subgraph,suspect,radius=3) name = str(random.random()) + "_graph" with d3py.NetworkXFigure(Anomalies_Subgraph, name=name,width=1000, height=1000) as p: p += d3py.ForceLayout() p.css['.node'] = {'fill': 'blue', 'stroke': 'magenta'} p.show()
def draw_d3_graph(RG): if module_exists('d3py'): import d3py with d3py.NetworkXFigure(RG, width=1500, height=1500) as p: p += d3py.ForceLayout() p.css['.node'] = {'fill': 'blue', 'stroke': 'magenta', 'title': 'bla'} p.css['.link'] = {'stroke': 'red', 'stoke-width': '3px'} p.show() else : print >> sys.stderr, 'Need to install Module: "d3py"' return
import pandas as pd import d3py import networkx as nx df = pd.DataFrame().from_csv("sna_example1.csv", index_col=False) G = nx.from_pandas_dataframe(df, "source", "target") with d3py.NetworkXFigure(G, name="graph", width=200, height=200) as p: p += d3py.ForceLayout() # To Do - add labels to d3py graphs p.css['.node'] = { 'fill': 'blue', 'stroke': 'magenta', 'label': 'test', "font-family": "Arial", "font-size": 12 } p.save() p.show()
import d3py import networkx as nx import logging logging.basicConfig(level=logging.DEBUG) G=nx.Graph() G.add_edge(1,2) G.add_edge(1,3) G.add_edge(3,2) G.add_edge(3,4) G.add_edge(4,2) # use 'with' if you are writing a script and want to serve this up forever with d3py.NetworkXFigure(G, width=500, height=500 , host='localhost') as p: p += d3py.ForceLayout() p.show()
import d3py import networkx as nx import logging logging.basicConfig(level=logging.DEBUG) G=nx.Graph() G.add_edge(1,2) G.add_edge(1,3) G.add_edge(3,2) G.add_edge(3,4) G.add_edge(4,2) # use 'with' if you are writing a script and want to serve this up forever with d3py.NetworkXFigure(G, width=500, height=500) as p: p += d3py.ForceLayout() p.show()