Package mrv :: Module dge :: Class Graph
[hide private]
[frames] | no frames]

Class Graph

source code

                  object --+        
                           |        
networkx.classes.graph.Graph --+    
                               |    
networkx.classes.digraph.DiGraph --+
                                   |
                  object --+       |
                           |       |
         interface.Interface --+   |
                               |   |
         interface.iDuplicatable --+
                                   |
                                  Graph
Known Subclasses:

Holds the nodes and their connections

Nodes are kept in a separate list whereas the plug connections are kept in the underlying DiGraph

Instance Methods [hide private]

Inherited from networkx.classes.digraph.DiGraph: add_edge, add_edges_from, add_node, add_nodes_from, clear, degree_iter, edges_iter, has_predecessor, has_successor, in_degree, in_degree_iter, in_edges, in_edges_iter, is_directed, is_multigraph, neighbors, neighbors_iter, out_degree, out_degree_iter, out_edges, out_edges_iter, predecessors, predecessors_iter, remove_edge, remove_edges_from, remove_node, remove_nodes_from, reverse, subgraph, successors, successors_iter, to_directed, to_undirected

Inherited from networkx.classes.graph.Graph: __contains__, __getitem__, __iter__, __len__, __str__, add_cycle, add_path, add_star, add_weighted_edges_from, adjacency_iter, adjacency_list, copy, degree, edges, get_edge_data, has_edge, has_node, nbunch_iter, nodes_iter, nodes_with_selfloops, number_of_edges, number_of_nodes, number_of_selfloops, order, selfloop_edges, size

Inherited from interface.iDuplicatable: copyTo, copyToOther, duplicate

Inherited from interface.Interface: supports

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

    Overridden Object Methods
 
__init__(self, **kwargs)
initialize the DiGraph and add some additional attributes
source code
 
__del__(self)
Clear our graph
source code
 
__getattr__(self, attr)
Allows access to nodes by name just by accessing the graph directly
source code
    Debugging
 
writeDot(self, fileOrPath)
Write the connections in self to the given file object or path :todo: remove if no longer needed
source code
    iDuplicatable Interface
 
createInstance(self)
Create a copy of self and return it
source code
 
copyFrom(self, other)
Duplicate all data from other graph into this one, create a duplicate of the nodes as well
source code
    Node Handling
 
addNode(self, node)
Add a new node instance to the graph :note: node membership is exclusive, thus node instances can only be in one graph at a time :return: self, for chained calls
source code
 
removeNode(self, node)
Remove the given node from the graph ( if it exists in it )
source code
 
clearCache(self)
Clear the cache of all nodes in the graph - this forces the graph to reevaluate on the next request
source code
    Query
 
hasNode(self, node)
Returns: True if the node is in this graph, false otherwise
source code
 
iterNodes(self, predicate=<function <lambda> at 0x2f590c8>)
Returns: generator returning all nodes in this graph
source code
 
iterConnectedNodes(self, predicate=<function <lambda> at 0x2f591b8>)
Returns: generator returning all nodes that are connected in this graph, in no particular order.
source code
 
nodes(self)
Returns: immutable copy of the nodes used in the graph
source code
 
numNodes(self)
Returns: number of nodes in the graph
source code
 
nodeByID(self, nodeID)
Returns: instance of a node according to the given node id
source code
    Connecitons
 
connect(self, sourceshell, destinationshell, force=False)
Connect this plug to destinationshell such that destinationshell is an input plug for our output
source code
 
disconnect(self, sourceshell, destinationshell)
Remove the connection between sourceshell to destinationshell if they are connected :note: does not raise if no connection is present
source code
 
input(self, plugshell)
Returns: the connected input plug of plugshell or None if there is no such connection
source code
 
outputs(self, plugshell, predicate=<function <lambda> at 0x2f59578>)
Returns: a list of plugs being the destination of the connection to plugshell
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 
initialize the DiGraph and add some additional attributes
Overrides: object.__init__

createInstance(self)

source code 
Create a copy of self and return it
Returns:
new instance of self
Overrides: interface.iDuplicatable.createInstance

copyFrom(self, other)

source code 
Duplicate all data from other graph into this one, create a duplicate of the nodes as well
Overrides: interface.iDuplicatable.copyFrom

hasNode(self, node)

source code 
Returns:
True if the node is in this graph, false otherwise

iterNodes(self, predicate=<function <lambda> at 0x2f590c8>)

source code 
Parameters:
  • predicate - if True for node, it will be returned
Returns:
generator returning all nodes in this graph

Note: there is no particular order

iterConnectedNodes(self, predicate=<function <lambda> at 0x2f591b8>)

source code 
Parameters:
  • predicate - if True for node, it will be returned
Returns:
generator returning all nodes that are connected in this graph, in no particular order. For an ordered itereration, use iterShells.

nodes(self)

source code 
Returns:
immutable copy of the nodes used in the graph
Overrides: networkx.classes.graph.Graph.nodes

numNodes(self)

source code 
Returns:
number of nodes in the graph

nodeByID(self, nodeID)

source code 
Returns:
instance of a node according to the given node id
Raises:
  • NameError - if no such node exists in graph

connect(self, sourceshell, destinationshell, force=False)

source code 
Connect this plug to destinationshell such that destinationshell is an input plug for our output
Parameters:
  • sourceshell - PlugShell being source of the connection
  • destinationshell - PlugShell being destination of the connection
  • force - if False, existing connections to destinationshell will not be broken, but an exception is raised if True, existing connection may be broken
Returns:
self on success, allows chained connections
Raises:

input(self, plugshell)

source code 
Returns:
the connected input plug of plugshell or None if there is no such connection

Note: input plugs have on plug at most, output plugs can have more than one connected plug

outputs(self, plugshell, predicate=<function <lambda> at 0x2f59578>)

source code 
Parameters:
  • predicate - plug will only be returned if predicate is true for it - shells will be passed in
Returns:
a list of plugs being the destination of the connection to plugshell