graph module

Graphing the program flow module.

This module aids in understanding the flow of program by creating a visual map (network graph or map) of the program flow path. The graph map is in DOT and GML (XML) types.

Required installation

  • pycallgraph (run pip install pycallgraph)
  • Graphviz visualization software

Author - Christopher Teh Boon Sung


Graph class

Graph class.

Creates a network map by showing/tracing the program flow. DOT and GML (XML) files will be created to show the flow. Use a dedicated Graph Editor like yEd to view the network map.

Inherits the pycallgraph.output.GraphvizOutput class to modify certain default output/behavior. Override the following base methods

    prepare_graph_attributes
    node
    edge
    done
    update

METHODS

  • trace: traces the program flow and creates (.dot) DOT and (.gml) GML files

Constructor __init__

Graph(self, **kwargs)

Create and initialize the Graph object.

Arguments

  • kwargs (dict): change any attributes or initialize new attributes with this dictionary

prepare_graph_attributes

Graph.prepare_graph_attributes(self)

Override to change the default attributes for graph, nodes, and edges.

Returns

None:

node

Graph.node(self, key, attr)

Override to delete newlines and number and length of function calls in node labels.

Returns

str: node label

edge

Graph.edge(self, edge, attr)

Override to delete edge labels.

Returns

str: edge label

done

Graph.done(self)

Override to avoid creating the graph picture file.

Returns

None:

update

Graph.update(self)

Override to avoid warning message to implement all abstract methods.

Does nothing.

Returns

None:

trace

Graph.trace(self, fn, fname, exclude_from_trace=None, strings_to_delete=None, class_colors=None)

Trace the program flow and creates DOT (.dot) and GML (.gml) files.

Arguments

  • fn (object): function to call for the entry point to trace the program flow
  • fname (str): filename for graph files (do not supply file extension)
  • exclude_from_trace (list): names (str) to exclude from trace (None by default)
  • strings_to_delete (list): text (str) to remove from graph files (None by default)
  • class_colors (dict): node colors (None by default)

Returns

None: