graphi.types.distance_graph module¶
-
class
graphi.types.distance_graph.
CachedDistanceGraph
(*source, **kwargs)¶ Bases:
graphi.types.distance_graph.DistanceGraph
Graph of nodes connected by a cached distance function
Compared to
DistanceGraph
, each edge is computed only once and stored for future lookup. Edges can be “deleted”, which sets their value to an infinite value.Parameters: - nodes – all nodes contained in the graph
- distance – a function dist(a, b)->object that computes the distance between any two nodes
- undirected – whether distance can be treated as undirected, i.e. dist(a, b) == dist(b, a)
Warning: For N nodes, all NxN edges are exposed and stored. This may lead to O(N:sup:2) runtime and memory complexity.
-
clear
()¶ Remove all elements from this graph
-
class
graphi.types.distance_graph.
DistanceGraph
(*args, **kwargs)¶ Bases:
graphi.abc.Graph
Graph of nodes connected by a distance function
Parameters: - nodes – all nodes contained in the graph
- distance – a function dist(a, b)->object that computes the distance between any two nodes
- undirected – whether distance can be treated as undirected, i.e. dist(a, b) == dist(b, a)
Warning: For N nodes, all NxN edges are exposed. This may lead to O(N:sup:2) runtime complexity.
-
clear
()¶ Remove all elements from this graph