yog/property/structure

Structural properties of graphs.

This module provides checks for various graph classes and regularities.

Algorithms

ProblemFunctionComplexity
Tree checkis_tree/1O(V + E)
Arborescence checkis_arborescence/1O(V + E)
Complete graph checkis_complete/1O(V)
Regular graph checkis_regular/2O(V)
Connected checkis_connected/1O(V + E)
Strongly connected checkis_strongly_connected/1O(V + E)
Weakly connected checkis_weakly_connected/1O(V + E)
Planar checkis_planar/1O(V + E)
Chordal checkis_chordal/1O(V + E)

Key Concepts

Values

pub fn arborescence_root(
  graph: model.Graph(n, e),
) -> option.Option(Int)

Finds the root of an arborescence.

Returns Some(root) if the graph is an arborescence, None otherwise.

pub fn is_arborescence(graph: model.Graph(n, e)) -> Bool

Checks if the graph is an arborescence (directed tree with a single root).

A directed graph is an arborescence iff:

  • It has n nodes and n-1 edges
  • Exactly one node has in-degree 0 (the root)
  • All other nodes have in-degree 1

Time Complexity: O(V + E)

pub fn is_chordal(graph: model.Graph(n, e)) -> Bool

Checks if the graph is chordal using Maximum Cardinality Search.

A chordal graph is one where every induced cycle has length 3.

Time Complexity: O(V + E)

pub fn is_complete(graph: model.Graph(n, e)) -> Bool

Checks if the graph is complete (every pair of distinct nodes is connected).

Time Complexity: O(V)

pub fn is_connected(graph: model.Graph(n, e)) -> Bool

Checks if the graph is connected.

For undirected graphs, every node is reachable from every other node. For directed graphs, this checks for strong connectivity.

Time Complexity: O(V + E)

pub fn is_planar(graph: model.Graph(n, e)) -> Bool

Checks if the graph is planar (necessary conditions only).

Implements necessary checks: |E| ≤ 3|V| - 6 and bipartite |E| ≤ 2|V| - 4.

Time Complexity: O(V + E)

pub fn is_regular(graph: model.Graph(n, e), k: Int) -> Bool

Checks if the graph is k-regular (every node has degree exactly k).

For directed graphs, both in-degree and out-degree must equal k.

Time Complexity: O(V)

pub fn is_strongly_connected(graph: model.Graph(n, e)) -> Bool

Checks if a directed graph is strongly connected.

For undirected graphs, falls back to is_connected/1.

Time Complexity: O(V + E)

pub fn is_tree(graph: model.Graph(n, e)) -> Bool

Checks if the graph is a tree (connected and acyclic). Works for undirected graphs.

Time Complexity: O(V + E)

pub fn is_weakly_connected(graph: model.Graph(n, e)) -> Bool

Checks if a directed graph is weakly connected.

For undirected graphs, falls back to is_connected/1.

Time Complexity: O(V + E)

Search Document