Package graph :: Module readwrite

Module readwrite

Functions for reading and writing graphs.

Functions
 
read_xml(graph, string)
Read a graph from a XML document.
string
write_xml(graph)
Return a string specifying the given graph as a XML document.
string
write_dot_graph(graph, wt)
Return a string specifying the given graph in DOT Language.
string
write_dot_digraph(graph, wt)
Return a string specifying the given digraph in DOT Language.
string
write_dot_hypergraph(hypergraph, coloured=False)
Return a string specifying the given hypergraph in DOT Language.
string
write_xml_hypergraph(hypergraph)
Return a string specifying the given hypergraph as a XML document.
 
read_xml_hypergraph(hypergraph, string)
Read a graph from a XML document.
Variables
  colors = ['aquamarine4', 'blue4', 'brown4', 'cornflowerblue', ...
Function Details

read_xml(graph, string)

 

Read a graph from a XML document. Nodes and edges specified in the input will be added to the current graph.

Parameters:
  • graph (graph) - Graph
  • string (string) - Input string in XML format specifying a graph.

write_xml(graph)

 

Return a string specifying the given graph as a XML document.

Parameters:
  • graph (graph) - Graph.
Returns: string
String specifying the graph as a XML document.

write_dot_graph(graph, wt)

 

Return a string specifying the given graph in DOT Language.

Parameters:
  • graph (graph) - Graph.
  • wt (boolean) - Whether edges should be labelled with its weight.
Returns: string
String specifying the graph in DOT Language.

write_dot_digraph(graph, wt)

 

Return a string specifying the given digraph in DOT Language.

Parameters:
  • graph (graph) - Graph.
  • wt (boolean) - Whether arrows should be labelled with its weight.
Returns: string
String specifying the graph in DOT Language.

write_dot_hypergraph(hypergraph, coloured=False)

 

Return a string specifying the given hypergraph in DOT Language.

Parameters:
  • hypergraph (hypergraph) - Hypergraph.
  • coloured (boolean) - Whether hyperedges should be coloured.
Returns: string
String specifying the hypergraph in DOT Language.

write_xml_hypergraph(hypergraph)

 

Return a string specifying the given hypergraph as a XML document.

Parameters:
  • hypergraph (hypergraph) - Hypergraph.
Returns: string
String specifying the graph as a XML document.

read_xml_hypergraph(hypergraph, string)

 

Read a graph from a XML document. Nodes and hyperedges specified in the input will be added to the current graph.

Parameters:
  • hypergraph (hypergraph) - Hypergraph
  • string (string) - Input string in XML format specifying a graph.

Variables Details

colors

Value:
['aquamarine4',
 'blue4',
 'brown4',
 'cornflowerblue',
 'cyan4',
 'darkgreen',
 'darkorange3',
 'darkorchid4',
...