Package pygraphlib :: Module pygraph :: Class DGraph
[show private | hide private]
[frames | no frames]

Class DGraph

Known Subclasses:
UGraph

Method Summary
  __init__(self, allow_self_loops, allow_multi_edges)
  __contains__(self, node)
Test whether a node is in the graph
  __iter__(self)
Iterates over all nodes in the graph
  __len__(self)
Returns the number of nodes
  __repr__(self)
User friendly and verbose representation
  __str__(self)
User friendly concise representation
  add_edge(self, head, tail, wt, data, create_nodes)
Adds a directed edge going from head to tail.
  add_node(self, node, data)
Creates a new node with a node.
  all_degree(self, node)
The total degree of a node
  all_edges(self, node)
Returns a list containing all incoming and outging edges
  all_nbrs(self, node)
Returns a list of nodes connected by incoming or outgoing edges.
  edge_data(self, edge)
Returns the data associated with an edge
  edge_head(self, edge)
Returns the head of the edge.
  edge_list(self)
Returns a list of all edge_ids in the graph
  edge_nodes(self, edge)
Returns the head and the tail of an edge.
  edge_tail(self, edge)
Returns the tail of the edge.
  get_edge(self, head, tail)
Returns the edge that connects the head to tail
  get_edge_data(self, edge)
Sets the data for an edge
  get_edge_wt(self, edge)
Gets the wt of the edge
  graph_error(self, msg)
Reports an error message
  hide_edge(self, edge)
Hides an edge from the graph.
  hide_node(self, node)
Hides a node from the graph.
  inc_degree(self, node)
Returns the number of incoming edges
  inc_edges(self, node)
Returns a list of the incoming edges
  inc_nbrs(self, node)
Returns a list of nodes connected by incoming edges.
  node_data(self, node)
Returns the data associated with a node
  node_list(self)
Returns a list of the nodes in the graph.
  number_of_edges(self)
Returns the number of edges
  number_of_hidden_edges(self)
Returns the number of hidden edges.
  number_of_hidden_nodes(self)
Returns the number of hidden nodes.
  number_of_nodes(self)
Returns the number of nodes
  out_degree(self, node)
Returns the number of outgoing edges
  out_edges(self, node)
Returns a list of the outgoing edges.
  out_nbrs(self, node)
Returns a list of nodes connected by outgoing edges.
  restore_all_edges(self)
Restores all hidden edges.
  restore_all_nodes(self)
Restores all hidden nodes.
  restore_edge(self, edge)
Restores a hidden edge.
  restore_node(self, node)
Restores a hidden node
  set_edge_data(self, edge_id, edge_data)
Fets the data for an edge
  set_edge_wt(self, edge, wt)
Sets the wt of the edge

Method Details

__init__(self, allow_self_loops=True, allow_multi_edges=True)
(Constructor)

>>> from pygraphlib import pygraph
>>> graph = pygraph.DGraph()
>>> graph.add_edge(1,2)
>>> print graph
DGraph: 2 nodes, 1 edges

__contains__(self, node)
(In operator)

Test whether a node is in the graph

__iter__(self)

Iterates over all nodes in the graph

__len__(self)
(Length operator)

Returns the number of nodes

__repr__(self)
(Representation operator)

User friendly and verbose representation

__str__(self)
(Informal representation operator)

User friendly concise representation

add_edge(self, head, tail, wt=1.0, data=None, create_nodes=True)

Adds a directed edge going from head to tail. The wt and edge_data parameters allow you to associate a numerical weight wt and/or arbitrary data with the edge. If create_nodes=True it will automatically create the non existing nodes.

add_node(self, node, data=None)

Creates a new node with a node. Arbitrary data can be attached to the node via the node_data parameter. Adding the same node twice will be silently ignored.

all_degree(self, node)

The total degree of a node

all_edges(self, node)

Returns a list containing all incoming and outging edges

all_nbrs(self, node)

Returns a list of nodes connected by incoming or outgoing edges.

edge_data(self, edge)

Returns the data associated with an edge

edge_head(self, edge)

Returns the head of the edge.

edge_list(self)

Returns a list of all edge_ids in the graph

edge_nodes(self, edge)

Returns the head and the tail of an edge.

edge_tail(self, edge)

Returns the tail of the edge.

get_edge(self, head, tail)

Returns the edge that connects the head to tail

get_edge_data(self, edge)

Sets the data for an edge

get_edge_wt(self, edge)

Gets the wt of the edge

graph_error(self, msg)

Reports an error message

hide_edge(self, edge)

Hides an edge from the graph.

hide_node(self, node)

Hides a node from the graph. >>> from pygraphlib import pygraph, algo >>> edges = [ (1,2), (2,3), (3,4), (4,6), (6,7), (3,5), (4,5), (7,1), (2,5), (5,7) ] >>> graph = pygraph.from_list(edges) >>> print graph DGraph: 7 nodes, 10 edges

inc_degree(self, node)

Returns the number of incoming edges

inc_edges(self, node)

Returns a list of the incoming edges

inc_nbrs(self, node)

Returns a list of nodes connected by incoming edges.

node_data(self, node)

Returns the data associated with a node

node_list(self)

Returns a list of the nodes in the graph.

number_of_edges(self)

Returns the number of edges

number_of_hidden_edges(self)

Returns the number of hidden edges.

number_of_hidden_nodes(self)

Returns the number of hidden nodes.

number_of_nodes(self)

Returns the number of nodes

out_degree(self, node)

Returns the number of outgoing edges

out_edges(self, node)

Returns a list of the outgoing edges.

out_nbrs(self, node)

Returns a list of nodes connected by outgoing edges.

restore_all_edges(self)

Restores all hidden edges.

restore_all_nodes(self)

Restores all hidden nodes.

restore_edge(self, edge)

Restores a hidden edge.

restore_node(self, node)

Restores a hidden node

set_edge_data(self, edge_id, edge_data)

Fets the data for an edge

set_edge_wt(self, edge, wt)

Sets the wt of the edge

Generated by Epydoc 2.1 on Wed Jan 5 09:38:28 2005 http://epydoc.sf.net