graphi.operators package¶

graphi.operators.
neighbours
(graph, *args, **kwargs)¶ Yield all nodes to which there is an outgoing edge from
node
ingraph
Parameters:  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
node
is not in the graphWhen
maximum_distance
is 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
, thennode
is 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 graph
has no nodesThe density is the ratio of actual edge count versus the maximum, nonlooping 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
.