edgegraph.builder.adjlist.load_adj_dict

Contents

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 Universe object.

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 vx values are Vertex instances (or subclasses thereof). The given example will produce the following structure:

object v0
object v1
object v2
object v3
object v4
object v5

v0 -- v1
v0 -- v2
v0 -- v3
v1 -- v2
v1 -- v3
v1 -- v4
v2 -- v3
v2 -- v4
v2 -- v5
v3 -- v3

Existing links between vertices are not checked or altered. If, in the above example, v0 was already linked to v2, 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.

Parameters:
  • adjdict (dict) – Adjacency dictionary as described above

  • linktype (type) – Class of links to use in creation. May be any subclass of TwoEndedLink; default is UnDirectedEdge.

Returns:

a Universe containing the graph described in adjdict.

Return type:

Universe