Node-edge graphs (indra.assemblers.graph_assembler)

class indra.assemblers.graph_assembler.GraphAssembler(stmts=None, graph_properties=None, node_properties=None, edge_properties=None)[source]

The Graph assembler assembles INDRA Statements into a Graphviz node-edge graph.

Parameters:
  • stmts (Optional[list[indra.statements.Statement]]) – A list of INDRA Statements to be added to the assembler’s list of Statements.
  • graph_properties (Optional[dict[str: str]]) – A dictionary of graphviz graph properties overriding the default ones.
  • node_properties (Optional[dict[str: str]]) – A dictionary of graphviz node properties overriding the default ones.
  • edge_properties (Optional[dict[str: str]]) – A dictionary of graphviz edge properties overriding the default ones.
statements

list[indra.statements.Statement] – A list of INDRA Statements to be assembled.

graph

pygraphviz.AGraph – A pygraphviz graph that is assembled by this assembler.

existing_nodes

list[tuple] – The list of nodes (identified by node key tuples) that are already in the graph.

existing_edges

list[tuple] – The list of edges (identified by edge key tuples) that are already in the graph.

graph_properties

dict[str: str] – A dictionary of graphviz graph properties used for assembly.

node_properties

dict[str: str] – A dictionary of graphviz node properties used for assembly.

edge_properties

dict[str: str] – A dictionary of graphviz edge properties used for assembly. Note that most edge properties are determined based on the type of the edge by the assembler (e.g. color, arrowhead). These settings cannot be directly controlled through the API.

add_statements(stmts)[source]

Add a list of statements to be assembled.

Parameters:stmts (list[indra.statements.Statement]) – A list of INDRA Statements to be appended to the assembler’s list.
get_string()[source]

Return the assembled graph as a string.

Returns:graph_string – The assembled graph as a string.
Return type:str
make_model()[source]

Assemble the graph from the assembler’s list of INDRA Statements.

save_dot(file_name='graph.dot')[source]

Save the graph in a graphviz dot file.

Parameters:file_name (Optional[str]) – The name of the file to save the graph dot string to.
save_pdf(file_name='graph.pdf', prog='dot')[source]

Draw the graph and save as an image or pdf file.

Parameters:
  • file_name (Optional[str]) – The name of the file to save the graph as. Default: graph.pdf
  • prog (Optional[str]) – The graphviz program to use for graph layout. Default: dot