Graph and Network Classes¶

Graphs and networks in SNAP are represented as undirected graphs TUNGraph, directed graphs TNGraph and multigraphs with attributes TNEANet.

TUNGraph¶

class TUNGraph
class TUNGraph(Nodes, Edges)

Returns a new undirected graph. If no parameters are provided, an empty graph is created. If Nodes and Edges are specified, space is preallocated for Nodes nodes and Edges edges. Do not call these methods directly! To create a new TUNGraph object, use one of the New() methods.

Nodes have IDs, which are arbitrary non-negative integers. Nodes and edges have no attributes/data associated with them. There is at most one undirected edge between a pair of nodes. Self loops (one per node) are allowed but multiple (parallel) edges are not. The undirected graph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree.

TUNGraph provides iterators for fast traversal of nodes and edges. Iterator classes are TUNGraphNodeI for iterating over nodes and TUNGraphEdgeI for iterating over edges.

TUNGraph provides the following methods:

New()

Returns a pointer to a new graph.

New(Nodes, Edges)

Returns a pointer to a new graph and reserves enough memory for Nodes nodes and Edges edges.

Loads a graph from a binary stream SIn and returns a pointer to it.

Save(SOut)

Saves the graph to a binary stream SOut.

Nodes()

Returns a generator for the nodes in the graph.

GetNodes()

Returns the number of nodes in the graph.

Adds a node of ID NId to the graph, NId is an integer. Returns node ID. If NId is -1, node ID is automatically assigned. It throws an exception, if a node with ID NId already exists.

Adds a node of ID NodeI.GetId() to the graph. NodeI is a node iterator. Returns node ID.

DelNode(NId)

Deletes node of ID NId from the graph. NId is an integer.

DelNode(NodeI)

Deletes node of ID NodeI.GetId() from the graph. NodeI is a node iterator.

IsNode(NId)

Returns true, if ID NId is a node in the graph.

BegNI()

Returns a node iterator referring to the first node in the graph.

EndNI()

Returns a node iterator referring to the past-the-end node in the graph.

GetNI(NId)

Returns a node iterator referring to the node of ID NId in the graph.

GetMxNId()

Returns an ID that is larger than any node ID in the graph.

GetRndNId()

Returns an ID of a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, for example with TRnd.Randomize(). The example below shows how to use Randomize(). Omit the line with Randomize() or the Rnd parameter to GetRndNId() to get the same return values for different program executions:

import snap
G = snap.GenFull(snap.TNEANet, 100)
Rnd = snap.TRnd(42)
Rnd.Randomize()
for i in range(0,10):
NId = G.GetRndNId(Rnd)
print(NId)
GetRndNI()

Returns a node iterator referring to a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

Edges()

Returns a generator for the edges in the graph.

GetEdges()

Returns the number of edges in the graph.

Adds an edge between node IDs SrcNId and DstNId to the graph. Returns -1, if the edge was successfully added. Returns -2, if the edge already exists. The function throws an exception, if SrcNId or DstNId are not nodes in the graph.

Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph. EdgeI is an edge iterator. Returns -1, if successful. Returns -2, otherwise.

DelEdge(SrcNId, DstNId)

Deletes an edge between node IDs SrcNId and DstNId from the graph. If the edge between SrcNId and DstNId does not exist in the graph, function still completes. But the function throws an exception, if SrcNId or DstNId are not nodes in the graph.

IsEdge(SrcNId, DstNId)

Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.

BegEI()

Returns an edge iterator referring to the first edge in the graph.

EndEI()

Returns an edge iterator referring to the past-the-end edge in the graph.

GetEI(SrcNId, DstNId)

Returns an edge iterator referring to edge between node IDs SrcNId and DstNId in the graph. Since this is an undirected graph GetEI(SrcNId, DstNId) has the same effect as GetEI(DstNId, SrcNId).

Empty()

Returns true if the graph is empty, has zero nodes.

Clr()

Deletes all nodes and edges from the graph.

Reserve(Nodes, Edges)

Reserves memory for a graph of Nodes nodes and Edges edges.

ReserveNIdDeg(NId, Deg)

Reserves memory for node ID NId having Deg edges.

HasFlag(Flag)

Allows for run-time checking the type of the graph (see the TGraphFlag for flag definitions).

Defrag()

Defragments the graph. After performing many node and edge insertions and deletions to a graph, the graph data structure can be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.

Dump(OutF=sys.stdout)

Prints the graph in a human readable form to the output stream OutF.

GetSmallGraph()

Returns a small graph on 5 nodes and 5 edges.

Below is some code demonstrating the use of the TUNGraph class:

>>> G1 = snap.TUNGraph.New()
1
2
5
-1
-1
>>> print(G1.Empty())
False
>>> print(G1.GetNodes())
3
>>> print(G1.GetEdges())
2

TUNGraphNodeI¶

class TUNGraphNodeI

Returns a new node iterator for TUNGraph. Normally, these objects are not created directly, but obtained via a call to the graph class TUNGraph method, such as BegNI(), that returns a node iterator.

TUNGraphNodeI provides the following methods:

Next()

Moves the iterator to the next node in the graph.

GetId()

Returns node ID of the current node.

GetDeg()
GetInDeg()
GetOutDeg()

Returns degree of the current node. Since the graph is undirected, all three methods return the same value.

GetInNId(NodeN)

Returns ID of NodeN-th in-node (the node pointing to the current node).

GetOutNId(NodeN)

Returns ID of NodeN-th out-node (the node the current node points to).

GetNbrNId(NodeN)

Returns ID of NodeN-th neighboring node.

IsInNId(NId)

Tests whether node with ID NId points to the current node.

IsOutNId(NId)

Tests whether the current node points to node with ID NId.

IsNbrNId(NId)

Tests whether node with ID NId is a neighbor of the current node.

TUNGraphEdgeI¶

class TUNGraphEdgeI

Returns a new edge iterator for TUNGraph. Normally, these objects are not created directly, but obtained via a call to the graph class TUNGraph method, such as BegEI(), that returns an edge iterator.

TUNGraphEdgeI provides the following methods:

Next()

Moves the iterator to the next edge in the graph.

GetId()

Returns a tuple of (SrcNId, DstNId). No explicit edge IDs are assigned to edges in TUNGraph.

GetSrcNId()

Returns the ID of the source node of the edge. Since the graph is undirected, this is the node with a smaller ID of the edge endpoints.

GetDstNId()

Returns the ID of the destination node of the edge. Since the graph is undirected, this is the node with a greater ID of the edge endpoints.

TNGraph¶

class TNGraph
class TNGraph(Nodes, Edges)

Returns a new directed graph. If no parameters are provided, an empty graph is created. If Nodes and Edges are specified, space is preallocated for Nodes nodes and Edges edges. Do not call these methods directly! To create a new TNGraph object, use one of the New() methods.

Nodes have IDs, which are arbitrary non-negative integers. Nodes and edges have no attributes/data associated with them. There is at most one directed edge from one source node to a destination node. There can be an edge between the same pair of nodes in the opposite direction. Self loops (one per node) are allowed but multiple (parallel) edges are not. The directed graph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing an arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree.

TNGraph provides iterators for fast traversal of nodes and edges. Iterator classes are TNGraphNodeI for iterating over nodes and TNGraphEdgeI for iterating over edges.

TNGraph provides the following methods:

New()

Returns a pointer to a new graph.

New(Nodes, Edges)

Returns a pointer to a new graph and reserves enough memory for Nodes nodes and Edges edges.

Loads a graph from a binary stream SIn and returns a pointer to it.

Save(SOut)

Saves the graph to a binary stream SOut.

Nodes()

Returns a generator for the nodes in the graph.

GetNodes()

Returns the number of nodes in the graph.

Adds a node of ID NId to the graph, NId is an integer. Returns node ID. If NId is -1, node ID is automatically assigned. It throws an exception, if a node with ID NId already exists.

Adds a node of ID NodeI.GetId() to the graph. NodeI is a node iterator. Returns node ID.

DelNode(NId)

Deletes node of ID NId from the graph. NId is an integer. If the node of ID NId does not exist, the function throws an exception.

DelNode(NodeI)

Deletes node of ID NodeI.GetId() from the graph. NodeI is a node iterator.

IsNode(NId)

Returns true, if ID NId is a node in the graph.

BegNI()

Returns a node iterator referring to the first node in the graph.

EndNI()

Returns a node iterator referring to the past-the-end node in the graph.

GetNI(NId)

Returns a node iterator referring to the node of ID NId in the graph.

GetMxNId()

Returns an ID that is larger than any node ID in the graph.

GetRndNId()

Returns an ID of a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

GetRndNI()

Returns a node iterator referring to a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

Edges()

Returns a generator for the edges in the graph.

GetEdges()

Returns the number of edges in the graph.

Adds an edge from node SrcNId to node DstNId to the graph. Returns -1, if the edge was successfully added. Returns -2, if the edge already exists. The function throws an exception, if SrcNId or DstNId are not nodes in the graph.

Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the graph. EdgeI is an edge iterator. Returns -1, if successful. Returns -2, otherwise.

DelEdge(SrcNId, DstNId)

Deletes an edge from node IDs SrcNId to DstNId from the graph. If the edge from SrcNId to DstNId does not exist in the graph, function still completes. But the function throws an exception, if SrcNId or DstNId are not nodes in the graph.

IsEdge(SrcNId, DstNId)

Tests whether an edge from node SrcNId to DstNId exists in the graph.

BegEI()

Returns an edge iterator referring to the first edge in the graph.

EndEI()

Returns an edge iterator referring to the past-the-end edge in the graph.

GetEI(SrcNId, DstNId)

Returns an edge iterator referring to edge between node IDs SrcNId and DstNId in the graph.

Empty()

Returns true if the graph is empty, has zero nodes.

Clr()

Deletes all nodes and edges from the graph.

Reserve(Nodes, Edges)

Reserves memory for a graph of Nodes nodes and Edges edges.

ReserveNIdInDeg(NId, Deg)

Reserves memory for node ID NId having InDeg in-edges.

ReserveNIdOutDeg(NId, Deg)

Reserves memory for node ID NId having OutDeg out-edges.

HasFlag(Flag)

Allows for run-time checking the type of the graph (see the TGraphFlag for flag definitions).

Defrag()

Defragments the graph. After performing many node and edge insertions and deletions to a graph, the graph data structure can be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.

Dump(OutF=sys.stdout)

Prints the graph in a human readable form to the output stream OutF.

GetSmallGraph()

Returns a small graph on 5 nodes and 6 edges.

Below is some code demonstrating the use of the TNGraph class:

>>> G2 = snap.TNGraph.New()
1
2
5
-1
-1
>>> print(G2.Empty())
False
>>> print(G2.GetNodes())
3
>>> print(G2.GetEdges())
2

TNGraphNodeI¶

class TNGraphNodeI

Returns a new node iterator for TNGraph. Normally, these objects are not created directly, but obtained via a call to the graph class TNGraph method, such as BegNI(), that returns a node iterator.

TNGraphNodeI provides the following methods:

Next()

Moves the iterator to the next node in the graph.

GetId()

Returns node ID of the current node.

GetDeg()

Returns degree of the current node, the sum of in-degree and out-degree.

GetInDeg()

Returns in-degree of the current node.

GetOutDeg()

Returns out-degree of the current node.

GetInNId(NodeN)

Returns ID of NodeN-th in-node (the node pointing to the current node).

GetOutNId(NodeN)

Returns ID of NodeN-th out-node (the node the current node points to).

GetNbrNId(NodeN)

Returns ID of NodeN-th neighboring node.

IsInNId(NId)

Tests whether node with ID NId points to the current node.

IsOutNId(NId)

Tests whether the current node points to node with ID NId.

IsNbrNId(NId)

Tests whether node with ID NId is a neighbor of the current node.

TNGraphEdgeI¶

class TNGraphEdgeI

Returns a new edge iterator for TNGraph. Normally, these objects are not created directly, but obtained via a call to the graph class TNGraph method, such as BegEI(), that returns an edge iterator.

TNGraphEdgeI provides the following methods:

Next()

Moves the iterator to the next edge in the graph.

GetId()

Returns a tuple of (SrcNId, DstNId). No explicit edge IDs are assigned to edges in TNGraph.

GetSrcNId()

Returns the ID of the source node of the edge.

GetDstNId()

Returns the ID of the destination node of the edge.

TNEANet¶

class TNEANet
class TNEANet(Nodes, Edges)

Returns a new directed multigraph with node and edge attributes. If no parameters are provided, an empty graph is created. If Nodes and Edges are specified, space is preallocated for Nodes nodes and Edges edges. Do not call these methods directly! To create a new TNEANet object, use one of the New() methods.

Nodes have IDs, which are arbitrary non-negative integers. Edges have IDs. There can be more than one directed edge from one source node to a destination node. Self loops (one per node) are allowed as well as multiple (parallel) edges. Nodes and edges can have attributes/data associated with them. The attributes can be added dynamically at runtime. The directed multigraph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree. The attributes are organized in a columnar store, where each attribute column is defined for all the nodes or edges in the network.

Methods for TNEANet are presented in two groups. The first group of methods deal with graph structure which includes nodes and edges. The second group of methods deal with node and edge attributes.

TNEANet provides iterators for fast traversal of nodes, edges and attributes. Iterator classes are TNEANetNodeI for iterating over nodes, TNEANetEdgeI for iterating over edges, and TNEANetAIntI, TNEANetAFltI, TNEANetAStrI for iterating over integer, float or string attributes, respectively. Attribute iterators can operate over attributes for nodes or edges.

TNEANet methods for graph structure are the following:

New()

Returns a pointer to a new graph.

New(Nodes, Edges)

Returns a pointer to a new graph and reserves enough memory for Nodes nodes and Edges edges.

Loads a graph from a binary stream SIn and returns a pointer to it.

Save(SOut)

Saves the graph to a binary stream SOut.

Nodes()

Returns a generator for the nodes in the graph.

GetNodes()

Returns the number of nodes in the graph.

Adds a node of ID NId to the graph, NId is an integer. Returns node ID. If NId is -1, node ID is automatically assigned. It throws an exception, if a node with ID NId already exists.

Adds a node of ID NodeI.GetId() to the graph. NodeI is a node iterator. Returns node ID.

DelNode(NId)

Deletes node of ID NId from the graph. NId is an integer. If the node of ID NId does not exist, the function throws an exception.

DelNode(NodeI)

Deletes node of ID NodeI.GetId() from the graph. NodeI is a node iterator.

IsNode(NId)

Returns true, if ID NId is a node in the graph.

BegNI()

Returns a node iterator referring to the first node in the graph.

EndNI()

Returns a node iterator referring to the past-the-end node in the graph.

GetNI(NId)

Returns a node iterator referring to the node of ID NId in the graph.

GetMxNId()

Returns an ID that is larger than any node ID in the graph.

GetRndNId()

Returns an ID of a random node in the graph. For this method to return different values on program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

GetNIdV(NIdV)

Returns IDs of all the nodes in vector NIdV, which must be of type TIntV.

Edges()

Returns a generator for the edges in the graph.

GetEdges()

Returns the number of edges in the graph.

Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph. Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Throws an exception, if an edge with ID EId already exists or if either SrcNId or DstNId does not exist.

Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the graph. EdgeI is an edge iterator. Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Throws an exception, if an edge with ID EId already exists or if either SrcNId or DstNId does not exist.

DelEdge(SrcNId, DstNId)

Deletes an edge from node IDs SrcNId to DstNId from the graph. If the edge from SrcNId to DstNId does not exist in the graph, function still completes. But the function throws an exception, if SrcNId or DstNId are not nodes in the graph.

IsEdge(SrcNId, DstNId)

Tests whether an edge from node SrcNId to DstNId exists in the graph.

BegEI()

Returns an edge iterator referring to the first edge in the graph.

EndEI()

Returns an edge iterator referring to the past-the-end edge in the graph.

GetEI(EId)

Returns an edge iterator referring to edge with ID EId.

GetEI(SrcNId, DstNId)

Returns an edge iterator referring to edge between node IDs SrcNId and DstNId in the graph.

GetRndEId()

Returns an ID of a random edge in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

GetEIdV(EIdV)

Returns IDs of all the edges in vector EIdV, which must be of type TIntV.

Empty()

Returns true if the graph is empty, has zero nodes.

Clr()

Deletes all nodes and edges from the graph.

Reserve(Nodes, Edges)

Reserves memory for a graph of Nodes nodes and Edges edges.

ReserveNIdInDeg(NId, Deg)

Reserves memory for node ID NId having InDeg in-edges.

ReserveNIdOutDeg(NId, Deg)

Reserves memory for node ID NId having OutDeg out-edges.

HasFlag(Flag)

Allows for run-time checking the type of the graph (see the TGraphFlag for flag definitions).

Defrag()

Defragments the graph. After performing many node and edge insertions and deletions to a graph, the graph data structure can be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.

Dump(OutF=sys.stdout)

Prints the graph in a human readable form to the output stream OutF.

GetSmallGraph()

Returns a small multigraph on 5 nodes and 6 edges.

TNEANet methods for node and edge attributes support attributes of different types. Integer, float and string attributes are implemented. Each attribute type has its own method for a particular task. Attributes are named via string names. The sections below describe methods for dealing with node attributes first, followed by methods for edge attributes.

TNEANet methods for node attributes are the following:

Defines a new integer, float or string node attribute, respectively.

DelAttrN(Attr)

Deletes node attribute Attr.

GetAttrIndN(Attr)

Returns the index of the value vector for node attribute Attr.

Sets the value of attribute named Attr for the node referred to by node iterator NodeI to Value. Value is an integer, a float, or a string, respectively.

Sets the value of attribute named Attr for the node with node id NId to Value. Value is an integer, a float, or a string, respectively.

GetIntAttrDatN(NodeI, Attr)
GetFltAttrDatN(NodeI, Attr)
GetStrAttrDatN(NodeI, Attr)

Returns the value of attribute named Attr for the node referred to by node iterator NodeI. Result is an integer, a float, or a string, respectively.

GetIntAttrDatN(NId, Attr)
GetFltAttrDatN(NId, Attr)
GetStrAttrDatN(NId, Attr)

Returns the value of attribute named Attr for the node with node id NId. Result is an integer, a float, or a string, respectively.

GetIntAttrIndDatN(NodeI, Index)
GetFltAttrIndDatN(NodeI, Index)
GetStrAttrIndDatN(NodeI, Index)

Returns the value of attribute at Index for the node referred to by node iterator NodeI. Result is an integer, a float, or a string, respectively.

GetIntAttrIndDatN(NId, Index)
GetFltAttrIndDatN(NId, Index)
GetStrAttrIndDatN(NId, Index)

Returns the value of attribute at Index for the node with node id NId. Result is an integer, a float, or a string, respectively.

BegNAIntI(Attr)
BegNAFltI(Attr)
BegNAStrI(Attr)

Returns an integer, float, or string attribute iterator, respectively, of the attribute named Attr referring to the first node.

EndNAIntI(Attr)
EndNAFltI(Attr)
EndNAStrI(Attr)

Returns an integer, float, or string attribute iterator, respectively, of the attribute named Attr referring to the past-the-end node.

GetNAIntI(Attr, NId)
GetNAFltI(Attr, NId)
GetNAStrI(Attr, NId)

Returns an integer, float, or string attribute iterator, respectively, of the attribute named Attr referring to the node with node ID NId.

DelAttrDatN(NodeI, Attr)

Deletes the value of attribute named Attr for the node referred to by node iterator NodeI.

DelAttrDatN(NId, Attr)

Deletes the value of attribute named Attr for the node with node ID NId.

IsAttrDeletedN(NId, Attr)

Returns true, if attribute Attr exists for node NId and has been deleted – its value is set to default.

IsIntAttrDeletedN(NId, Attr)
IsFltAttrDeletedN(NId, Attr)
IsStrAttrDeletedN(NId, Attr)

Returns true, if integer, float, or string attribute Attr exists for node NId and has been deleted – its value is set to default.

AttrNameNI(NId, NameV)

Provides names of attributes for the node NId. Only attributes with an assigned value are provided. Attribute names are returned as strings in NameV, which must be of type TStrV.

IntAttrNameNI(NId, NameV)
FltAttrNameNI(NId, NameV)
StrAttrNameNI(NId, NameV)

Provides names of integer, float, or string attributes for the node NId, respectively. Only attributes with an assigned value are provided. Attribute names are returned as strings in NameV, which must be of type TStrV.

AttrValueNI(NId, ValueV)

Provides values of attributes for the node NId. Only attributes with an assigned value are provided. Attribute values are converted to strings and returned in ValueV, which must be of type TStrV.

IntAttrValueNI(NId, ValueV)
FltAttrValueNI(NId, ValueV)
StrAttrValueNI(NId, ValueV)

Provides values of integer, float, or string attributes for the node NId, respectively. Only attributes with an assigned value are provided. Attribute values are returned as integers, floats, or strings in ValueV, which must be of type TIntV, TFltV, or TStrV, respectively.

TNEANet methods for edge attributes are the following:

Defines a new integer, float or string edge attribute, respectively.

DelAttrE(Attr)

Deletes edge attribute Attr.

GetAttrIndE(Attr)

Returns the index of the value vector for edge attribute Attr.

Sets the value of attribute named Attr for the edge referred to by edge iterator EdgeI to Value. Value is an integer, a float, or a string, respectively.

Sets the value of attribute named Attr for the edge with edge id EId to Value. Value is an integer, a float, or a string, respectively.

GetIntAttrDatE(EdgeI, Attr)
GetFltAttrDatE(EdgeI, Attr)
GetStrAttrDatE(EdgeI, Attr)

Returns the value of attribute named Attr for the edge referred to by edge iterator EdgeI. Result is an integer, a float, or a string, respectively.

GetIntAttrDatE(EId, Attr)
GetFltAttrDatE(EId, Attr)
GetStrAttrDatE(EId, Attr)

Returns the value of attribute named Attr for the edge with edge id EId. Result is an integer, a float, or a string, respectively.

GetIntAttrIndDatE(EdgeI, Index)
GetFltAttrIndDatE(EdgeI, Index)
GetStrAttrIndDatE(EdgeI, Index)

Returns the value of attribute at Index for the edge referred to by edge iterator EdgeI. Result is an integer, a float, or a string, respectively.

GetIntAttrIndDatE(EId, Index)
GetFltAttrIndDatE(EId, Index)
GetStrAttrIndDatE(EId, Index)

Returns the value of attribute at Index for the edge with edge id EId. Result is an integer, a float, or a string, respectively.

BegEAIntI(Attr)
BegEAFltI(Attr)
BegEAStrI(Attr)

Returns an integer, float, or string attribute iterator, respectively, of the attribute named Attr referring to the first edge.

EndEAIntI(Attr)
EndEAFltI(Attr)
EndEAStrI(Attr)

Returns an integer, float, or string attribute iterator, respectively, of the attribute named Attr referring to the past-the-end edge.

GetEAIntI(Attr, EId)
GetEAFltI(Attr, EId)
GetEAStrI(Attr, EId)

Returns an integer, float, or string attribute iterator, respectively, of the attribute named Attr referring to the edge with edge ID EId.

DelAttrDatE(EdgeI, Attr)

Deletes the value of attribute named Attr for the edge referred to by edge iterator EdgeI.

DelAttrDatE(EId, Attr)

Deletes the value of attribute named Attr for the edge with edge ID EId.

IsAttrDeletedE(EId, Attr)

Returns true, if attribute Attr exists for edge EId and has been deleted – its value is set to default.

IsIntAttrDeletedE(EId, Attr)
IsFltAttrDeletedE(EId, Attr)
IsStrAttrDeletedE(EId, Attr)

Returns true, if integer, float, or string attribute Attr exists for edge EId and has been deleted – its value is set to default.

AttrNameEI(EId, NameV)

Provides names of attributes for the edge EId. Only attributes with an assigned value are provided. Attribute names are returned as strings in NameV, which must be of type TStrV.

IntAttrNameEI(EId, NameV)
FltAttrNameEI(EId, NameV)
StrAttrNameEI(EId, NameV)

Provides names of integer, float, or string attributes for the edge EId, respectively. Only attributes with an assigned value are provided. Attribute names are returned as strings in NameV, which must be of type TStrV.

AttrValueEI(EId, ValueV)

Provides values of attributes for the edge EId. Only attributes with an assigned value are provided. Attribute values are converted to strings and returned in ValueV, which must be of type TStrV.

IntAttrValueEI(EId, ValueV)
FltAttrValueEI(EId, ValueV)
StrAttrValueEI(EId, ValueV)

Provides values of integer, float, or string attributes for the edge EId, respectively. Only attributes with an assigned value are provided. Attribute values are returned as integers, floats, or strings in ValueV, which must be of type TIntV, TFltV, or TStrV, respectively.

AttrValueEI(EId, ValueV)

Provides values of attributes for the edge EId. Only attributes with an assigned value are provided. Attribute values are converted to strings and returned in ValueV, which must be of type TStrV.

TNEANet also provides methods for sparse attributes. NOTE these methods are currently under development:

Adds attribute with name AttrName or attribtue id AttrId for the given node with id NId. Val can be an int, float, or string.

GetSAttrDatN(NId, AttrName, Val)
GetSAttrDat(NId, AttrId, Val)

Gets attribute with name AttrName or attribute id AttrId for the given node with id NId. Resulting value is stored in Val.

DelSAttrDatN(NId, AttrId)

Delete attribute with name AttrName or attribute id AttrId for the given node with id NId.

GetSAttrVN(NId, AttrType, AttrV)

Get a list of all attributes of type AttrType for the given node with id NId. AttrType should be one of IntType, FltType, or StrType. AttrV stores the results - a list of pairs, where each pair gives the attribute name and type. The type is TAttrPrV.

GetIdVSAttrN(AttrName, IdV)
GetIdVSAttrN(AttrId, IdV)

Get a list of all nodes that have an attribute with name AttrName or id AttrId.

Adds a mapping for an attribute with name Name and type AttrType. AttrId is updated with the assigned attribute integer id.

GetSAttrIdN(Name, AttrId, AttrType)

Given the node attribute name Name, get the attribute id.

GetSAttrNameN(AttrId, Name, AttrType)

Given the node attribute id AttrId, get the attribute name.

Adds attribute with name AttrName or attribtue id AttrId for the given edge with id EId. Val can be an int, float, or string.

GetSAttrDatE(EId, AttrName, Val)
GetSAttrDatE(EId, AttrId, Val)

Gets attribute with name AttrName or attribute id AttrId for the given edge with id EId. Resulting value is stored in Val.

DelSAttrDat(EId, AttrId)

Delete attribute with name AttrName or attribute id AttrId for the given edge with id EId.

GetSAttrVE(EId, AttrType, AttrV)

Get a list of all attributes of type AttrType for the given edge with id EId. AttrType should be one of IntType, FltType, or StrType. AttrV stores the results - a list of pairs, where each pair gives the attribute name and type. The type is TAttrPrV.

GetIdVSAttrE(AttrName, IdV)
GetIdVSAttrE(AttrId, IdV)

Get a list of all edges that have an attribute with name AttrName or id AttrId.

Adds a mapping for an attribute with name Name and type AttrType. AttrId is updated with the assigned attribute integer id.

GetSAttrIdE(Name, AttrId, AttrType)

Given the edge attribute name Name, get the attribute id.

GetSAttrNameE(AttrId, Name, AttrType)

Given the edge attribute id AttrId, get the attribute name.

Below is some code demonstrating the use of the TNEANet class:

>>> G3 = snap.TNEANet.New()
1
2
5
0
1
2
>>> print(G3.Empty())
False
>>> print(G3.GetNodes())
3
>>> print(G3.GetEdges())
3

TNEANetNodeI¶

class TNEANetNodeI

Returns a new node iterator for TNEANet. Normally, these objects are not created directly, but obtained via a call to the network class TNEANet method, such as BegNI(), that returns a node iterator.

TNEANetNodeI provides the following methods:

Next()

Moves the iterator to the next node in the graph.

GetId()

Returns node ID of the current node.

GetDeg()

Returns degree of the current node, the sum of in-degree and out-degree.

GetInDeg()

Returns in-degree of the current node.

GetOutDeg()

Returns out-degree of the current node.

GetInNId(NodeN)

Returns ID of NodeN-th in-node (the node pointing to the current node).

GetOutNId(NodeN)

Returns ID of NodeN-th out-node (the node the current node points to).

GetNbrNId(NodeN)

Returns ID of NodeN-th neighboring node.

IsInNId(NId)

Tests whether node with ID NId points to the current node.

IsOutNId(NId)

Tests whether the current node points to node with ID NId.

IsNbrNId(NId)

Tests whether node with ID NId is a neighbor of the current node.

TNEANetEdgeI¶

class TNEANetEdgeI

Returns a new edge iterator for TNEANet. Normally, these objects are not created directly, but obtained via a call to the graph class TNEANet method, such as BegEI(), that returns an edge iterator.

TNEANetEdgeI provides the following methods:

Next()

Moves the iterator to the next edge in the graph.

GetId()

Returns edge ID.

GetSrcNId()

Returns the ID of the source node of the edge.

GetDstNId()

Returns the ID of the destination node of the edge.

TNEANetAIntI, TNEANetAFltI, TNEANetAStrI¶

class TNEANetAIntI
class TNEANetAFltI
class TNEANetAStrI

Returns a new integer, float or string attribute iterator for TNEANet. Normally, these objects are not created directly, but obtained via a call to the graph class TNEANet method, such as BegNAIntI(), which returns an integer node iterator, or BegEAFltI(), which returns a float edge iterator.

Attribute iterators provide the following methods:

Next()

Moves the iterator to the next node or edge in the graph.

GetDat()

Returns an attribute of the node or edge.

IsDeleted()

Returns true if the attribute has been deleted.

TUndirNet¶

class TUndirNet
class TUndirNet(Nodes, Edges)

Returns a new undirected graph. If no parameters are provided, an empty graph is created. If Nodes and Edges are specified, space is preallocated for Nodes nodes and Edges edges. Do not call these methods directly! To create a new TUndirNet object, use one of the New() methods.

Nodes have IDs, which are arbitrary non-negative integers. Nodes and edges have no attributes/data associated with them. There is at most one undirected edge between a pair of nodes. Self loops (one per node) are allowed but multiple (parallel) edges are not. The undirected graph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree.

TUndirNet provides iterators for fast traversal of nodes and edges. Iterator classes are TUndirNetNodeI for iterating over nodes and TUndirNetEdgeI for iterating over edges.

TUndirNet provides the following methods:

New()

Returns a pointer to a new graph.

New(Nodes, Edges)

Returns a pointer to a new graph and reserves enough memory for Nodes nodes and Edges edges.

Loads a graph from a binary stream SIn and returns a pointer to it.

Save(SOut)

Saves the graph to a binary stream SOut.

GetNodes()

Returns the number of nodes in the graph.

Adds a node of ID NId to the graph, NId is an integer. Returns node ID. If NId is -1, node ID is automatically assigned. It throws an exception, if a node with ID NId already exists.

Adds a node of ID NodeI.GetId() to the graph. NodeI is a node iterator. Returns node ID.

DelNode(NId)

Deletes node of ID NId from the graph. NId is an integer.

DelNode(NodeI)

Deletes node of ID NodeI.GetId() from the graph. NodeI is a node iterator.

IsNode(NId)

Returns true, if ID NId is a node in the graph.

BegNI()

Returns a node iterator referring to the first node in the graph.

EndNI()

Returns a node iterator referring to the past-the-end node in the graph.

GetNI(NId)

Returns a node iterator referring to the node of ID NId in the graph.

GetMxNId()

Returns an ID that is larger than any node ID in the graph.

GetEdges()

Returns the number of edges in the graph.

Adds an edge between node IDs SrcNId and DstNId to the graph. Returns -1, if the edge was successfully added. Returns -2, if the edge already exists. The function throws an exception, if SrcNId or DstNId are not nodes in the graph.

Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph. EdgeI is an edge iterator. Returns -1, if successful. Returns -2, otherwise.

DelEdge(SrcNId, DstNId)

Deletes an edge between node IDs SrcNId and DstNId from the graph. If the edge between SrcNId and DstNId does not exist in the graph, function still completes. But the function throws an exception, if SrcNId or DstNId are not nodes in the graph.

IsEdge(SrcNId, DstNId)

Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.

BegEI()

Returns an edge iterator referring to the first edge in the graph.

EndEI()

Returns an edge iterator referring to the past-the-end edge in the graph.

GetEI(SrcNId, DstNId)

Returns an edge iterator referring to edge between node IDs SrcNId and DstNId in the graph. Since this is an undirected graph GetEI(SrcNId, DstNId) has the same effect as GetEI(DstNId, SrcNId).

GetRndNId()

Returns an ID of a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

GetRndNI()

Returns a node iterator referring to a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

Empty()

Returns true if the graph is empty, has zero nodes.

Clr()

Deletes all nodes and edges from the graph.

Reserve(Nodes, Edges)

Reserves memory for a graph of Nodes nodes and Edges edges.

ReserveNIdDeg(NId, Deg)

Reserves memory for node ID NId having Deg edges.

HasFlag(Flag)

Allows for run-time checking the type of the graph (see the TGraphFlag for flag definitions).

Defrag()

Defragments the graph. After performing many node and edge insertions and deletions to a graph, the graph data structure can be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.

Dump(OutF=sys.stdout)

Prints the graph in a human readable form to the output stream OutF.

GetSmallGraph()

Returns a small graph on 5 nodes and 5 edges.

TUndirNet also provides methods for sparse attributes. NOTE these methods are currently under development:

Adds attribute with name AttrName or attribtue id AttrId for the given node with id NId. Val can be an int, float, or string.

GetSAttrDatN(NId, AttrName, Val)
GetSAttrDat(NId, AttrId, Val)

Gets attribute with name AttrName or attribute id AttrId for the given node with id NId. Resulting value is stored in Val.

DelSAttrDatN(NId, AttrId)

Delete attribute with name AttrName or attribute id AttrId for the given node with id NId.

GetSAttrVN(NId, AttrType, AttrV)

Get a list of all attributes of type AttrType for the given node with id NId. AttrType should be one of IntType, FltType, or StrType. AttrV stores the results - a list of pairs, where each pair gives the attribute name and type. The type is TAttrPrV.

GetIdVSAttrN(AttrName, IdV)
GetIdVSAttrN(AttrId, IdV)

Get a list of all nodes that have an attribute with name AttrName or id AttrId.

Adds a mapping for an attribute with name Name and type AttrType. AttrId is updated with the assigned attribute integer id.

GetSAttrIdN(Name, AttrId, AttrType)

Given the node attribute name Name, get the attribute id.

GetSAttrNameN(AttrId, Name, AttrType)

Given the node attribute id AttrId, get the attribute name.

Adds attribute with name AttrName or attribtue id AttrId for the given edge from SrcNId to DstNId. Val can be an int, float, or string.

GetSAttrDatE(SrcNId, DstNId, AttrName, Val)
GetSAttrDatE(SrcNId, DstNId, AttrId, Val)

Gets attribute with name AttrName or attribute id AttrId for the given edge from SrcNId to DstNId. Resulting value is stored in Val.

DelSAttrDat(SrcNId, DstNId, AttrId)

Delete attribute with name AttrName or attribute id AttrId for the given edge from SrcNId to DstNId.

GetSAttrVE(SrcNId, DstNId, AttrType, AttrV)

Get a list of all attributes of type AttrType for the given edge from SrcNId to DstNId. AttrType should be one of IntType, FltType, or StrType. AttrV stores the results - a list of pairs, where each pair gives the attribute name and type. The type is TAttrPrV.

GetIdVSAttrE(AttrName, IdV)
GetIdVSAttrE(AttrId, IdV)

Get a list of all edges that have an attribute with name AttrName or id AttrId. IdV is a list of integer pairs, giving the source and destination node ids.

Adds a mapping for an attribute with name Name and type AttrType. AttrId is updated with the assigned attribute integer id.

GetSAttrIdE(Name, AttrId, AttrType)

Given the edge attribute name Name, get the attribute id.

GetSAttrNameE(AttrId, Name, AttrType)

Given the edge attribute id AttrId, get the attribute name.

Below is some code demonstrating the use of the TUndirNet class:

>>> G1 = snap.TUndirNet.New()
1
2
5
-1
-1
>>> print(G1.Empty())
False
>>> print(G1.GetNodes())
3
>>> print(G1.GetEdges())
2

TUndirNetNodeI¶

class TUndirNetNodeI

Returns a new node iterator for TUndirNet. Normally, these objects are not created directly, but obtained via a call to the graph class TUndirNet method, such as BegNI(), that returns a node iterator.

TUndirNetNodeI provides the following methods:

Next()

Moves the iterator to the next node in the graph.

GetId()

Returns node ID of the current node.

GetDeg()
GetInDeg()
GetOutDeg()

Returns degree of the current node. Since the graph is undirected, all three methods return the same value.

GetInNId(NodeN)

Returns ID of NodeN-th in-node (the node pointing to the current node).

GetOutNId(NodeN)

Returns ID of NodeN-th out-node (the node the current node points to).

GetNbrNId(NodeN)

Returns ID of NodeN-th neighboring node.

IsInNId(NId)

Tests whether node with ID NId points to the current node.

IsOutNId(NId)

Tests whether the current node points to node with ID NId.

IsNbrNId(NId)

Tests whether node with ID NId is a neighbor of the current node.

TUndirNetEdgeI¶

class TUndirNetEdgeI

Returns a new edge iterator for TUndirNet. Normally, these objects are not created directly, but obtained via a call to the graph class TUndirNet method, such as BegEI(), that returns an edge iterator.

TUndirNetEdgeI provides the following methods:

Next()

Moves the iterator to the next edge in the graph.

GetId()

Always returns -1 for TUndirNet, since edges do not have explicit IDs.

GetSrcNId()

Returns the ID of the source node of the edge. Since the graph is undirected, this is the node with a smaller ID of the edge endpoints.

GetDstNId()

Returns the ID of the destination node of the edge. Since the graph is undirected, this is the node with a greater ID of the edge endpoints.

TDirNet¶

class TDirNet
class TDirNet(Nodes, Edges)

Returns a new directed graph. If no parameters are provided, an empty graph is created. If Nodes and Edges are specified, space is preallocated for Nodes nodes and Edges edges. Do not call these methods directly! To create a new TDirNet object, use one of the New() methods.

Nodes have IDs, which are arbitrary non-negative integers. Nodes and edges have no attributes/data associated with them. There is at most one directed edge from one source node to a destination node. There can be an edge between the same pair of nodes in the opposite direction. Self loops (one per node) are allowed but multiple (parallel) edges are not. The directed graph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing an arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree.

TDirNet provides iterators for fast traversal of nodes and edges. Iterator classes are TDirNetNodeI for iterating over nodes and TDirNetEdgeI for iterating over edges.

TDirNet provides the following methods:

New()

Returns a pointer to a new graph.

New(Nodes, Edges)

Returns a pointer to a new graph and reserves enough memory for Nodes nodes and Edges edges.

Loads a graph from a binary stream SIn and returns a pointer to it.

Save(SOut)

Saves the graph to a binary stream SOut.

GetNodes()

Returns the number of nodes in the graph.

Adds a node of ID NId to the graph, NId is an integer. Returns node ID. If NId is -1, node ID is automatically assigned. It throws an exception, if a node with ID NId already exists.

Adds a node of ID NodeI.GetId() to the graph. NodeI is a node iterator. Returns node ID.

DelNode(NId)

Deletes node of ID NId from the graph. NId is an integer. If the node of ID NId does not exist, the function throws an exception.

DelNode(NodeI)

Deletes node of ID NodeI.GetId() from the graph. NodeI is a node iterator.

IsNode(NId)

Returns true, if ID NId is a node in the graph.

BegNI()

Returns a node iterator referring to the first node in the graph.

EndNI()

Returns a node iterator referring to the past-the-end node in the graph.

GetNI(NId)

Returns a node iterator referring to the node of ID NId in the graph.

GetMxNId()

Returns an ID that is larger than any node ID in the graph.

GetEdges()

Returns the number of edges in the graph.

Adds an edge from node SrcNId to node DstNId to the graph. Returns -1, if the edge was successfully added. Returns -2, if the edge already exists. The function throws an exception, if SrcNId or DstNId are not nodes in the graph.

Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the graph. EdgeI is an edge iterator. Returns -1, if successful. Returns -2, otherwise.

DelEdge(SrcNId, DstNId)

Deletes an edge from node IDs SrcNId to DstNId from the graph. If the edge from SrcNId to DstNId does not exist in the graph, function still completes. But the function throws an exception, if SrcNId or DstNId are not nodes in the graph.

IsEdge(SrcNId, DstNId)

Tests whether an edge from node SrcNId to DstNId exists in the graph.

BegEI()

Returns an edge iterator referring to the first edge in the graph.

EndEI()

Returns an edge iterator referring to the past-the-end edge in the graph.

GetEI(SrcNId, DstNId)

Returns an edge iterator referring to edge between node IDs SrcNId and DstNId in the graph.

GetRndNId()

Returns an ID of a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

GetRndNI()

Returns a node iterator referring to a random node in the graph. For this method to return different values on subsequent program executions, the random generator must be seeded first, see the example under TUNGraph.GetRndNId().

Empty()

Returns true if the graph is empty, has zero nodes.

Clr()

Deletes all nodes and edges from the graph.

Reserve(Nodes, Edges)

Reserves memory for a graph of Nodes nodes and Edges edges.

ReserveNIdInDeg(NId, Deg)

Reserves memory for node ID NId having InDeg in-edges.

ReserveNIdOutDeg(NId, Deg)

Reserves memory for node ID NId having OutDeg out-edges.

HasFlag(Flag)

Allows for run-time checking the type of the graph (see the TGraphFlag for flag definitions).

Defrag()

Defragments the graph. After performing many node and edge insertions and deletions to a graph, the graph data structure can be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.

Dump(OutF=sys.stdout)

Prints the graph in a human readable form to the output stream OutF.

GetSmallGraph()

Returns a small graph on 5 nodes and 6 edges.

TDirNet also provides methods for sparse attributes. NOTE these methods are currently under development:

Adds attribute with name AttrName or attribtue id AttrId for the given node with id NId. Val can be an int, float, or string.

GetSAttrDatN(NId, AttrName, Val)
GetSAttrDat(NId, AttrId, Val)

Gets attribute with name AttrName or attribute id AttrId for the given node with id NId. Resulting value is stored in Val.

DelSAttrDatN(NId, AttrId)

Delete attribute with name AttrName or attribute id AttrId for the given node with id NId.

GetSAttrVN(NId, AttrType, AttrV)

Get a list of all attributes of type AttrType for the given node with id NId. AttrType should be one of IntType, FltType, or StrType. AttrV stores the results - a list of pairs, where each pair gives the attribute name and type. The type is TAttrPrV.

GetIdVSAttrN(AttrName, IdV)
GetIdVSAttrN(AttrId, IdV)

Get a list of all nodes that have an attribute with name AttrName or id AttrId.

Adds a mapping for an attribute with name Name and type AttrType. AttrId is updated with the assigned attribute integer id.

GetSAttrIdN(Name, AttrId, AttrType)

Given the node attribute name Name, get the attribute id.

GetSAttrNameN(AttrId, Name, AttrType)

Given the node attribute id AttrId, get the attribute name.

Adds attribute with name AttrName or attribtue id AttrId for the given edge from SrcNId to DstNId. Val can be an int, float, or string.

GetSAttrDatE(SrcNId, DstNId, AttrName, Val)
GetSAttrDatE(SrcNId, DstNId, AttrId, Val)

Gets attribute with name AttrName or attribute id AttrId for the given edge from SrcNId to DstNId. Resulting value is stored in Val.

DelSAttrDat(SrcNId, DstNId, AttrId)

Delete attribute with name AttrName or attribute id AttrId for the given edge from SrcNId to DstNId.

GetSAttrVE(SrcNId, DstNId, AttrType, AttrV)

Get a list of all attributes of type AttrType for the given edge from SrcNId to DstNId. AttrType should be one of IntType, FltType, or StrType. AttrV stores the results - a list of pairs, where each pair gives the attribute name and type. The type is TAttrPrV.

GetIdVSAttrE(AttrName, IdV)
GetIdVSAttrE(AttrId, IdV)

Get a list of all edges that have an attribute with name AttrName or id AttrId. IdV is a list of integer pairs, giving the source and destination node ids.

Adds a mapping for an attribute with name Name and type AttrType. AttrId is updated with the assigned attribute integer id.

GetSAttrIdE(Name, AttrId, AttrType)

Given the edge attribute name Name, get the attribute id.

GetSAttrNameE(AttrId, Name, AttrType)

Given the edge attribute id AttrId, get the attribute name.

Below is some code demonstrating the use of the TDirNet class:

>>> G2 = snap.TDirNet.New()
1
2
5
-1
-1
>>> print(G2.Empty())
False
>>> print(G2.GetNodes())
3
>>> print(G2.GetEdges())
2

TDirNetNodeI¶

class TDirNetNodeI

Returns a new node iterator for TDirNet. Normally, these objects are not created directly, but obtained via a call to the graph class TDirNet method, such as BegNI(), that returns a node iterator.

TDirNetNodeI provides the following methods:

Next()

Moves the iterator to the next node in the graph.

GetId()

Returns node ID of the current node.

GetDeg()

Returns degree of the current node, the sum of in-degree and out-degree.

GetInDeg()

Returns in-degree of the current node.

GetOutDeg()

Returns out-degree of the current node.

GetInNId(NodeN)

Returns ID of NodeN-th in-node (the node pointing to the current node).

GetOutNId(NodeN)

Returns ID of NodeN-th out-node (the node the current node points to).

GetNbrNId(NodeN)

Returns ID of NodeN-th neighboring node.

IsInNId(NId)

Tests whether node with ID NId points to the current node.

IsOutNId(NId)

Tests whether the current node points to node with ID NId.

IsNbrNId(NId)

Tests whether node with ID NId is a neighbor of the current node.

TDirNetEdgeI¶

class TDirNetEdgeI

Returns a new edge iterator for TDirNet. Normally, these objects are not created directly, but obtained via a call to the graph class TDirNet method, such as BegEI(), that returns an edge iterator.

TDirNetEdgeI provides the following methods:

Next()

Moves the iterator to the next edge in the graph.

GetId()

Always returns -1 for TDirNet, since edges do not have explicit IDs.

GetSrcNId()

Returns the ID of the source node of the edge.

GetDstNId()

Returns the ID of the destination node of the edge.