dynetx.classes.function.degree

dynetx.classes.function.degree(G, nbunch=None, t=None)

Return the degree of a node or nodes at time t.

The node degree is the number of edges adjacent to that node.

Parameters:
  • G (Graph opject) – DyNetx graph object
  • nbunch (iterable container, optional (default=all nodes)) – A container of nodes. The container will be iterated through once.
  • t (snapshot id (default=None)) – If None will be returned the degree of nodes on the flattened graph.
Returns:

nd – A dictionary with nodes as keys and degree as values or a number if a single node is specified.

Return type:

dictionary, or number

Examples

>>> G = dn.DynGraph()
>>> G.add_path([0,1,2,3], t=0)
>>> dn.degree(G, 0, t=0)
1
>>> dn.degree(G, [0,1], t=1)
{0: 0, 1: 0}
>>> list(dn.degree(G, [0,1], t=0).values())
[1, 2]