def __init__(self, data=None, name='', weighted=True): """Initialize an empty graph. Examples -------- >>> G=nx.Graph() >>> G=nx.Graph(name='my graph') >>> G=nx.Graph(weighted=False) # don't assume edge data are weights """ self.adj = {} # empty adjacency hash self.weighted = weighted # attempt to load graph with data if data is not None: convert.from_whatever(data,create_using=self) self.name = name
def __init__(self, data=None, name='', weighted=True): """Initialize an empty graph. Examples -------- >>> G=nx.Graph() >>> G=nx.Graph(name='my graph') >>> G=nx.Graph(weighted=False) # don't assume edge data are weights """ self.adj = {} # empty adjacency hash self.weighted = weighted # attempt to load graph with data if data is not None: convert.from_whatever(data, create_using=self) self.name = name
def __init__(self, data=None, **kwds): Tree.__init__(self, **kwds) self.comp = {} # dictionary mapping node to component self.nc = 0 # component index, start at zero, sequential (with holes) if data is not None: try: self = convert.from_whatever(data, create_using=self) except: raise NetworkXError("Data %s is not a forest" % data)
def __init__(self,data=None,**kwds): Tree.__init__(self,**kwds) self.comp={} # dictionary mapping node to component self.nc=0 # component index, start at zero, sequential (with holes) if data is not None: try: self=convert.from_whatever(data,create_using=self) except: raise NetworkXError("Data %s is not a forest"%data)
def __init__(self, data=None, name='', weighted=True): """Initialize an empty directed graph. Examples -------- >>> G=nx.DiGraph() >>> G=nx.DiGraph(name='my graph') >>> G=nx.DiGraph(weighted=False) # don't assume edge data are weights """ # We store two adjacency lists: # the predecessors of node n are stored in the dict self.pred # the successors of node n are stored in the dict self.succ=self.adj self.adj = {} # empty adjacency dictionary self.pred = {} # predecessor self.succ = self.adj # successor self.weighted = weighted # attempt to load graph with data if data is not None: convert.from_whatever(data,create_using=self) self.name=name
def __init__(self, data=None, name='', weighted=True): """Initialize an empty directed graph. Examples -------- >>> G=nx.DiGraph() >>> G=nx.DiGraph(name='my graph') >>> G=nx.DiGraph(weighted=False) # don't assume edge data are weights """ # We store two adjacency lists: # the predecessors of node n are stored in the dict self.pred # the successors of node n are stored in the dict self.succ=self.adj self.adj = {} # empty adjacency dictionary self.pred = {} # predecessor self.succ = self.adj # successor self.weighted = weighted # attempt to load graph with data if data is not None: convert.from_whatever(data, create_using=self) self.name = name
def __init__(self, data=None, **kwds): Graph.__init__(self, **kwds) if data is not None: try: # build a graph G = Graph() G = convert.from_whatever(data, create_using=G) except: raise NetworkXError, "Data %s is not a tree" % data # check if it is a tree. if G.order()==G.size()+1 and \ component.number_connected_components(G)==1: self.adj = G.adj.copy() del G else: raise NetworkXError, "Data %s is not a tree" % data
def __init__(self,data=None,**kwds): Graph.__init__(self,**kwds) if data is not None: try: # build a graph G=Graph() G=convert.from_whatever(data,create_using=G) except: raise NetworkXError, "Data %s is not a tree"%data # check if it is a tree. if G.order()==G.size()+1 and \ component.number_connected_components(G)==1: self.adj=G.adj.copy() del G else: raise NetworkXError, "Data %s is not a tree"%data
def __init__(self, data=None, name='', selfloops=False, multiedges=False, ubigraph_server= 'http://127.0.0.1:20738/RPC2', clear=True, nextid=0): import xmlrpclib try: server_url = ubigraph_server self.server = xmlrpclib.Server(server_url) self.ubigraph = self.server.ubigraph if clear: self.ubigraph.clear() except: raise IOError("No Ubigraph server found") # default node and edge styles self.ubigraph.set_vertex_style_attribute(0, "color", "#ff0000") self.ubigraph.set_vertex_style_attribute(0, "shape", "sphere") self.ubigraph.set_vertex_style_attribute(0, "size", "0.7") self.ubigraph.set_edge_style_attribute(0, "color", "#ffffff") self.ubigraph.set_edge_style_attribute(0, "width", "2.0") self.use_splines=False self.use_node_labels=False self.use_edge_labels=False # keep a mapping from nodes to ubigraph ids self.nodeid={} self.nextid=nextid self.idnode={} self.adj={} # adjacency list self.selfloops=selfloops self.multiedges=multiedges if data is not None: self=convert.from_whatever(data,create_using=self) self.name=name
def __init__(self, data=None, name='', selfloops=False, multiedges=False, ubigraph_server='http://127.0.0.1:20738/RPC2', clear=True, nextid=0): import xmlrpclib try: server_url = ubigraph_server self.server = xmlrpclib.Server(server_url) self.ubigraph = self.server.ubigraph if clear: self.ubigraph.clear() except: raise IOError("No Ubigraph server found") # default node and edge styles self.ubigraph.set_vertex_style_attribute(0, "color", "#ff0000") self.ubigraph.set_vertex_style_attribute(0, "shape", "sphere") self.ubigraph.set_vertex_style_attribute(0, "size", "0.7") self.ubigraph.set_edge_style_attribute(0, "color", "#ffffff") self.ubigraph.set_edge_style_attribute(0, "width", "2.0") self.use_splines = False self.use_node_labels = False self.use_edge_labels = False # keep a mapping from nodes to ubigraph ids self.nodeid = {} self.nextid = nextid self.idnode = {} self.adj = {} # adjacency list self.selfloops = selfloops self.multiedges = multiedges if data is not None: self = convert.from_whatever(data, create_using=self) self.name = name