edgegraph.builder.adjlist.load_adj_dict#
- edgegraph.builder.adjlist.load_adj_dict(adjdict, linktype=<class 'edgegraph.structure.undirectededge.UnDirectedEdge'>)#
Load an “adjacency dictionary” to create a
Universeobject.The input structure is expected to be of the following structure:
adjdict = { v0: [v1, v2, v3], # these don't have to be *lists* -- v1: [v2, v3, v4], # only iterable objects v2: [v3, v4, v5], v3: [v3], # origin in list -> self-edge v5: [] # empty list -> no edges }
where all
vxvalues areVertexinstances (or subclasses thereof). The given example will produce the following structure:Existing links between vertices are not checked or altered. If, in the above example,
v0was already linked tov2, this function would create another link between those vertices.Attention
This process has side effects on the vertices that are a part of the adjacency dictionary! They are all added to a new universe and linked to the other vertices given.
See also
The
create_adj_dict()function is more-or-less the inverse of this one, accepting a Universe as an argument and returning an adjacency dictionary.- Parameters:
adjdict (dict) – Adjacency dictionary as described above
linktype (type) – Class of links to use in creation. May be any subclass of
TwoEndedLink; default isUnDirectedEdge.
- Returns:
a Universe containing the graph described in
adjdict.- Return type: