This module provides tools for creating and using graph skeletons for Bayesian networks. A graph skeleton in this case is a vertex set and a directed edge set, with no further information about the specific nodes.
This class represents a graph skeleton, meaning a vertex set and a directed edge set. It contains the attributes V and E, and the methods load, getparents, getchildren, and toporder.
A list of names of vertices.
A list of [origin, destination] pairs of vertices that constitute edges.
(Inherited from dictionary) A variable that stores a key-indexable dictionary once it is loaded from a file.
Load the graph skeleton from a text file located at path.
Text file must be a plaintext .txt file with a JSON-style representation of a dict. Dict must contain the top-level keys “V” and “E” with the following formats:
{
'V': ['<vertex_name_1>', ... , '<vertex_name_n'],
'E': [['vertex_of_origin', 'vertex_of_destination'], ... ]
}
Return the parents of vertex in the graph skeleton.
Return the children of vertex in the graph skeleton.
Modify the vertices of the graph skeleton such that they are in topological order.
A topological order is an order of vertices such that if there is an edge from u to v, u appears before v in the ordering. It works only for directed ayclic graphs.
The function also checks for cycles in the graph, and returns an error if one is found.