Data.Graph.Decomposition
- Package
- purescript-hylograph-graph
- Repository
- afcondon/purescript-hylograph-graph
Graph decomposition algorithms for structural analysis.
Algorithms for identifying structural features that suggest visualization strategies:
- Biconnected Components: maximal 2-connected subgraphs
- Articulation Points: vertices whose removal disconnects the graph
- Bridges: edges whose removal disconnects the graph
- Bipartiteness: 2-colorability test with witness
- Block-Cut Tree: tree of blocks + cut vertices (the chimera skeleton)
All algorithms work with SimpleGraph (undirected interpretation).
Complexity is O(V + E) unless noted otherwise.
#biconnectedComponents Source
biconnectedComponents :: forall node. Ord node => SimpleGraph node -> Array (Set (Tuple node node))Find all biconnected components (as sets of edges). Each component is a maximal subgraph with no cut vertex.
#articulationPoints Source
articulationPoints :: forall node. Ord node => SimpleGraph node -> Set nodeFind all articulation points (cut vertices). A vertex is an articulation point if removing it disconnects the graph.
#bridges Source
bridges :: forall node. Ord node => SimpleGraph node -> Array (Tuple node node)Find all bridges (cut edges). An edge is a bridge iff it is the sole edge in a biconnected component.
#detectBipartite Source
detectBipartite :: forall node. Ord node => SimpleGraph node -> Either (Array node) { partA :: Set node, partB :: Set node }Test if a graph is bipartite.
Returns Right (partA, partB) if bipartite, or Left oddCycle if not.
#blockCutTree Source
blockCutTree :: forall node. Ord node => SimpleGraph node -> { blocks :: Array (Set node), cutVertices :: Set node, tree :: Array { from :: Int, to :: Int } }Build the block-cut tree from a graph. The tree's internal structure mirrors how the graph decomposes: blocks (dense subgraphs) connected at cut vertices (junction points).
#decompositionMetrics Source
decompositionMetrics :: forall node. Ord node => SimpleGraph node -> DecompositionMetricsCompute structural decomposition metrics for a graph
#TestGraphs Source
type TestGraphs = { barbell :: SimpleGraph String, bowtie :: SimpleGraph String, cycle5 :: SimpleGraph String, cycle6 :: SimpleGraph String, diamond :: SimpleGraph String, k33 :: SimpleGraph String, k5 :: SimpleGraph String, path4 :: SimpleGraph String, star8 :: SimpleGraph String, tree10 :: SimpleGraph String }#testGraphs Source
testGraphs :: TestGraphsCollection of canonical test graphs with known properties