graphi.types.adjacency_graph module

class graphi.types.adjacency_graph.AdjacencyGraph(*args, **kwargs)

Bases: graphi.abc.Graph

Graph storing edge distances via adjacency lists

Parameters:
  • source – adjacency information
  • undirected – whether the graph enforces symmetry

This graph provides optimal performance for random, direct access to nodes and edges. As it stores individual nodes and edges, it is optimal in both space and time for sparse graphs.

However, ordering of nodes(), edges() and values() is arbitrary. The expected complexity for searches is the worst case of O(len(nodes()) = n) and O(len(edges()) -> n2), respectively.

clear()

Remove all elements from this graph

edges()

Return a new view of the graph’s edges

Returns:view of the graph’s edges
Return type:EdgeView
update(other)

Update the graph with the nodes, edges and values from other, overwriting existing elements.

Parameters:other (Graph or ItemView) – graph or items from which to pull elements
values()

Return a new view of the values of the graph’s edges

Returns:view of the values of the graph’s edges
Return type:ValueView
class graphi.types.adjacency_graph.EdgeView(graph)

Bases: graphi.abc.EdgeView

View on the edges in a graph

class graphi.types.adjacency_graph.ValueView(graph)

Bases: graphi.abc.ValueView

View on the values of edges in a graph