graphi.operators package

graphi.operators.neighbours(graph, *args, **kwargs)

Yield all nodes to which there is an outgoing edge from node in graph

  • graph (Graph) – graph in which to search for edges
  • node – node from which edges originate.
  • maximum_distance – maximum distance to other nodes

iterator of neighbour nodes


NodeError – if node is not in the graph

When maximum_distance is not None, it is the maximum allowed edge value. This is interpreted using the <= operator as graph[edge] <= distance.

If there is a valid edge graph[node:node] <= distance, then node is part of its own neighbourhood.

Note:The order of neighbours is arbitrary.
graphi.operators.density(graph, *args, **kwargs)

Return the density of the graph, i.e. the connectedness of its nodes

Parameters:graph (Graph) – graph for which to calculate density
Raises:ValueError – if graph has no nodes

The density is the ratio of actual edge count versus the maximum, non-looping edge count.

A graph without edges has a density of 0, whereas a complete graph has a density of 1. A graph with a loop may have a density bigger than 1. The density is undefined for a graph less than two nodes, and raises ValueError.