Action requires login

Base node representation.

Nodes have seven properties:

  • incoming, which is a list of all edges coming into this node
  • outgoing, which is a list of all edges going away from this node
  • bidirectional, which is a list of all bidirectional edges incident
    to this node
  • edges, which is a list of all edges with this node as an endpoint
  • degree, which is the number of edges incident to this node
  • data, which is a dictionary of all non-private (ie, user-defined)
    attributes of this node
  • and name, which is a unique, non-None value optionally passed in
    at instantiation time, and used for hashing comparisons.

In the event that a name is not passed in, the object’s id
will be used.

Properties


def incoming(self):

   Returns a list of all the incoming edges for this node.

   Note that the list returned is a copy, so modifying it doesn't  
   impact the structure of the graph.  

def outgoing(self):

   Returns a list of all the outgoing edges for this node.

   Note that the list returned is a copy, so modifying it doesn't  
   impact the structure of the graph.  

def bidirectional(self):

    Returns a list of all bidirectional edges for this node.

    Note that the list returned is a copy, so modifying it doesn't  
    impact the structure of the graph.  

def edges(self):

    Returns a list of all edges for this node.

    Note that the list returned is a copy, so modifying it doesn't  
    impact the structure of the graph.  

def degree(self):

    Returns the degree of this Node, ie, the number of edges.

Constructors


def __init__(self, name=None, **kwargs):

   Initializes the Node object.

   Accepts an optional name argument and a variable number of kwargs.

   If a name is provided, it can be accessed through the .name property.

   If a name is not provided, one will be automatically generated based  
   on the object's id.

   The kwargs are mapped into attributes.

   Usage:  
   >>> n = Node("bob", weight=5)
   >>> n.name  
   bob  
   >>> n.weight  
   5

Functions


def get_adjacent(self, outgoing=True, incoming=False):

   Returns a list of all adjacent nodes.

   The optional arguments outgoing and incoming indicate  
   whether to include those edge sets in the search field.  
   Their defaults are True and False, accordingly.

   If provided, outgoing and incoming should be booleans.