graphi.operators package¶
-
graphi.operators.neighbours(graph, *args, **kwargs)¶ Yield all nodes to which there is an outgoing edge from
nodeingraphParameters: - graph (
Graph) – graph in which to search for edges - node – node from which edges originate.
- maximum_distance – maximum distance to other nodes
Returns: iterator of neighbour nodes
Raises: NodeError – if
nodeis not in the graphWhen
maximum_distanceis notNone, it is the maximum allowed edge value. This is interpreted using the<=operator asgraph[edge] <= distance.If there is a valid edge
graph[node:node] <= distance, thennodeis part of its own neighbourhood.Note: The order of neighbours is arbitrary. - graph (
-
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 densityRaises: ValueError – if graphhas no nodesThe 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 of1. A graph with a loop may have a density bigger than1. The density is undefined for a graph less than two nodes, and raisesValueError.