Class UndirectedGraph

java.lang.Object
jline.util.graph.UndirectedGraph

public class UndirectedGraph extends Object
An undirected graph data structure with weighted edges represented as an adjacency matrix.

This class provides graph algorithms for undirected graphs including connected component detection and graph analysis. The adjacency matrix is symmetric, with edges (i,j) and (j,i) having the same weight.

Key features:

  • Weakly connected component (WCC) detection
  • Symmetric adjacency matrix representation
  • Weighted edge support with normalization options
  • Column filtering for selective analysis

See Also:
  • Constructor Details

    • UndirectedGraph

      public UndirectedGraph(Matrix param, Set<Integer> colsToIgnore)
      Constructs an undirected graph with the given adjacency matrix and column filter. Weights for bidirectional edges are summed.
      Parameters:
      param - adjacency matrix where entry (i,j) represents edge weight
      colsToIgnore - set of column indices to ignore, can be null
    • UndirectedGraph

      public UndirectedGraph(Matrix param, Set<Integer> colsToIgnore, boolean normalize)
      Constructs an undirected graph with optional weight normalization.
      Parameters:
      param - adjacency matrix where entry (i,j) represents edge weight
      colsToIgnore - set of column indices to ignore, can be null
      normalize - if true, weights are averaged for links (i,j) and (j,i); if false, weights are summed
    • UndirectedGraph

      public UndirectedGraph(Matrix param)
  • Method Details

    • addEdge

      public void addEdge(int s, int d, double weight)
    • computeWeaklyConnectedComponents

      public void computeWeaklyConnectedComponents()
    • findCC

      public void findCC(int i, boolean[] visited, Set<Integer> chain)
    • getWCC

      public Set<Set<Integer>> getWCC()
    • toMatrix

      public Matrix toMatrix()