# StatGraphs -- a package for graphs used in statistical models

## Description

This package contains the types of graphs that are used in algebraic statistics: Bigraph and MixedGraph.

A bigraph is graph with bidirected edges and no multiple edges. A mixed graph is a graph with undirected, directed and bidirected edges.

This is an example of a bigraph on 4 vertices. It is created using the method bigraph.

 i1 : G = bigraph {{3,4},{1,2},{2,4}} o1 = Bigraph{1 => {2} } 2 => {4, 1} 3 => {4} 4 => {3, 2} o1 : Bigraph

Next is an example of a mixed graph on 4 vertices with undirected, directed and bidirected edges. It is created using the method mixedGraph.

 i2 : G = mixedGraph(graph{{1,2}},digraph {{1,3},{2,3}},bigraph {{3,4}}) o2 = MixedGraph{Bigraph => Bigraph{3 => {4}}} 4 => {3} Digraph => Digraph{1 => {3}} 2 => {3} 3 => {} Graph => Graph{1 => {2}} 2 => {1} o2 : MixedGraph

One can extract key information about mixed graphs using: undirectedGraph(MixedGraph), bigraph(MixedGraph), digraph(MixedGraph), vertices(MixedGraph),

or convert a mixed graph into a more convenient form using: collateVertices(MixedGraph), indexLabelGraph(MixedGraph).

There are several methods that allow to check the properties of mixed graphs: isCyclic(MixedGraph), isLoopless(MixedGraph), isSimple(MixedGraph).

One can also study the properties of vertices using: children(MixedGraph,Thing), parents(MixedGraph,Thing), descendants(MixedGraph,Thing), nondescendants(MixedGraph,Thing), forefathers(MixedGraph,Thing), neighbors(MixedGraph,Thing), nonneighbors(MixedGraph,Thing).

This package allows to construct loopless mixed graphs (LMG) as introduced in Kayvan Sadeghi and Steffen Lauritzen, Markov properties for mixed graphs, Bernoulli 20.2 (2014): 676-696 and to check whether a mixedGraph is an LMG using partitionLMG.

## Caveat

StatGraphs requires Graphs version 0.3.3 or later.

## Version

This documentation describes version 0.1 of StatGraphs.

## Source code

The source code from which this documentation is derived is in the file StatGraphs.m2.

## Exports

• Types
• Bigraph -- a graph with bidirected edges and no multiple edges
• MixedGraph -- a graph that has undirected, directed and bidirected edges
• Functions and commands
• bigraph -- create a bigraph
• collateVertices -- convert a mixed graph into a new mixed graph where each component subgraph has the same set of vertices
• isLoopless -- check whether a graph contains a loop
• mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• partitionLMG -- partition the vertices of a loopless mixed graph into adjacent to undirected edges and adjacent to bidirected edges
• undirectedGraph -- extract the undirected graph component of a mixed graph
• Methods
• "bigraph(HashTable)" -- see bigraph -- create a bigraph
• "bigraph(List)" -- see bigraph -- create a bigraph
• "bigraph(List,List)" -- see bigraph -- create a bigraph
• "bigraph(List,Matrix)" -- see bigraph -- create a bigraph
• "bigraph(Matrix)" -- see bigraph -- create a bigraph
• bigraph(MixedGraph) -- extract the bigraph component of a mixed graph
• children(MixedGraph,Thing) -- return the children of a vertex of a mixed graph
• "collateVertices(MixedGraph)" -- see collateVertices -- convert a mixed graph into a new mixed graph where each component subgraph has the same set of vertices
• descendants(MixedGraph,Thing) -- return the descendants of a vertex of a mixed graph
• digraph(MixedGraph) -- extract the digraph component of a mixed graph
• forefathers(MixedGraph,Thing) -- return the forefathers of a vertex of a mixed graph
• graph(MixedGraph) -- convert mixed graph to a hash table
• indexLabelGraph(MixedGraph) -- relabel the vertices of a mixed graph according to their indices, indexed from 0
• isCyclic(MixedGraph) -- check whether a mixed graph contains a directed cycle
• "isLoopless(Bigraph)" -- see isLoopless -- check whether a graph contains a loop
• "isLoopless(Digraph)" -- see isLoopless -- check whether a graph contains a loop
• "isLoopless(Graph)" -- see isLoopless -- check whether a graph contains a loop
• "isLoopless(MixedGraph)" -- see isLoopless -- check whether a graph contains a loop
• isSimple(MixedGraph) -- check whether a mixed graph is simple
• "mixedGraph(Bigraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Bigraph,Digraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Bigraph,Digraph,Graph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Bigraph,Graph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Bigraph,Graph,Digraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Digraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Digraph,Bigraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Digraph,Bigraph,Graph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Digraph,Graph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Digraph,Graph,Bigraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Graph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Graph,Bigraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Graph,Bigraph,Digraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Graph,Digraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• "mixedGraph(Graph,Digraph,Bigraph)" -- see mixedGraph -- create a mixed graph from a combination of undirected graph, digraph and bigraph
• neighbors(MixedGraph,Thing) -- return the neighbors of a vertex of a mixed graph
• net(MixedGraph) -- print a mixed graph as a net
• nondescendants(MixedGraph,Thing) -- return the nondescendents of a vertex of a mixed graph
• nonneighbors(MixedGraph,Thing) -- return the neighbors of a vertex of a mixed graph
• parents(MixedGraph,Thing) -- return the parents of a vertex of a mixed graph
• "partitionLMG(MixedGraph)" -- see partitionLMG -- partition the vertices of a loopless mixed graph into adjacent to undirected edges and adjacent to bidirected edges
• toString(MixedGraph) -- print a mixed graph as a string
• "undirectedGraph(MixedGraph)" -- see undirectedGraph -- extract the undirected graph component of a mixed graph
• "vertexSet(MixedGraph)" -- see vertices(MixedGraph) -- create a union of all vertices of a mixed graph
• vertices(MixedGraph) -- create a union of all vertices of a mixed graph

## For the programmer

The object StatGraphs is .