forked from networkx/networkx
-
Notifications
You must be signed in to change notification settings - Fork 0
Design Specification
Dan Schult edited this page Feb 11, 2015
·
4 revisions
Proposed API for Reporting from Di/Multi/Graph
- nodes() - iterator over nodes
- neighbors(n, data=False, default=None, combine_multiedges=None) - iterator over neighbors of n.
- If data is True: iterator over (nbr, eattr_dict)
- if data not in (False,True): iterator over (nbr, eattr_dict[data])
- MultiGraph
- If data is True: combine all edges between neighbors using combine_multiedges(keydict.values())
- If data is not in (False,True): combine all edges between neighbors using combine_multiedges(dd[data] for dd in keydict.values())
- degree(nbunch=None, weight=None) - iterator over (n, deg(n))
- if nbunch is not None: only iterate over nodes in nbunch… single node->single value
- if weight is not None: deg(n) is sum of weights on edges instead of number of edges
- edges(nbunch=None, data=False, keys=None, default=None) - iterator of 2-tuples (undirected only once)
- if nbunch is not None: iterator of edges from nodes in nbunch (undirected only once)
- if data is True: iterator of edge info (n,nbr,eattr_dict)
- if data not in (False,True): 3-tuple (n,nbr,eattr_dict.get(data,default))
- MultiGraph
- if data/key is True/None: iterator of edge info (n,nbr,keydict)
- if data/key is False/True: iterator of 3-tuple edge (n,nbr,key)
- if data/key is True/True: iterator of 4-tuple edge (n,nbr,key,eattr_dict)
- if data not in (True,None): 4-tuple (n,nbr,key,eattr[data])
- get_edge_data(u, v, data=None, key=None) eattr_dict for edge between u,v
- if data is not None: eattr[data] for edge between u,v
- MultiGraph
- if key is None, return eattr_keydict, otherwise look at edge u,v,key
- adjacency_iter(data=None) - iterator of (n, {nbr:eattr, ...})
- if data is not None: eattr replaced by eattr[data] For Directed Graphs we also have in/out_neighbors, in/out_edges, in/out_degree. Neighbors and edges are out_neighbors and out_edges. Degree is the sum of in_degree and out_degree.