Package logilab :: Package common :: Module graph

[frames] | no frames]

# Module graph

source code

    Graph manipulation utilities.

    (dot generation adapted from pypy/translator/tool/make_dot.py)

Classes
| __metaclass__ type(object) -> the object's type type(name, bases, dict) -> a new type
| DotBackend Dot File backend.
| GraphGenerator
| UnorderableGraph

Functions

escape(value) Make <value> usable in a dot file. | source code

target_info_from_filename(filename) Transforms /some/path/foo.png into ('/some/path', 'foo.png', 'png'). | source code

normalize_node_id(nid) Returns a suitable DOT node id for `nid`. | source code

ordered_nodes(graph) takes a dependency graph dict as arguments and return an ordered tuple of nodes starting with nodes without dependencies and up to the outermost node. | source code

get_cycles(graph_dict, vertices=None) given a dictionary representing an ordered graph (i.e. | source code

has_path(graph_dict, fromnode, tonode, path=None) generic function taking a simple graph definition as a dictionary, with node has key associated to a list of nodes directly reachable from it. | source code

Function Details

### ordered_nodes(graph)

source code

    takes a dependency graph dict as arguments and return an ordered tuple of
    nodes starting with nodes without dependencies and up to the outermost node.

    If there is some cycle in the graph, :exc:`UnorderableGraph` will be raised.

    Also the given graph dict will be emptied.

### get_cycles(graph_dict, vertices=None)

source code

    given a dictionary representing an ordered graph (i.e. key are vertices
    and values is a list of destination vertices representing edges), return a
    list of detected cycles

### has_path(graph_dict, fromnode, tonode, path=None)

source code

    generic function taking a simple graph definition as a dictionary, with
    node has key associated to a list of nodes directly reachable from it.

    Return None if no path exists to go from `fromnode` to `tonode`, else the
    first path found (as a list including the destination node at last)