Class UndirectedGraph<V>

java.lang.Object
org.episteme.core.mathematics.discrete.UndirectedGraph<V>
All Implemented Interfaces:
Graph<V>

public class UndirectedGraph<V> extends Object implements Graph<V>
Adjacency list implementation of an undirected graph.
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • UndirectedGraph

      public UndirectedGraph()
  • Method Details

    • vertices

      public Set<V> vertices()
      Description copied from interface: Graph
      Returns all vertices in this graph.
      Specified by:
      vertices in interface Graph<V>
      Returns:
      unmodifiable set of vertices
    • vertexCount

      public int vertexCount()
      Description copied from interface: Graph
      Returns the number of vertices in the graph.
      Specified by:
      vertexCount in interface Graph<V>
      Returns:
      the number of vertices
    • edges

      public Set<Graph.Edge<V>> edges()
      Description copied from interface: Graph
      Returns all edges in this graph.
      Specified by:
      edges in interface Graph<V>
      Returns:
      unmodifiable set of edges
    • addVertex

      public boolean addVertex(V vertex)
      Description copied from interface: Graph
      Adds a vertex to the graph.
      Specified by:
      addVertex in interface Graph<V>
      Parameters:
      vertex - the vertex to add
      Returns:
      true if vertex was added, false if already present
    • addEdge

      public boolean addEdge(V source, V target)
      Description copied from interface: Graph
      Adds an edge between two vertices.
      Specified by:
      addEdge in interface Graph<V>
      Parameters:
      source - the source vertex
      target - the target vertex
      Returns:
      true if edge was added
    • neighbors

      public Set<V> neighbors(V vertex)
      Description copied from interface: Graph
      Returns neighbors of a vertex.
      Specified by:
      neighbors in interface Graph<V>
      Parameters:
      vertex - the vertex
      Returns:
      set of adjacent vertices
    • degree

      public int degree(V vertex)
      Description copied from interface: Graph
      Returns the degree (number of edges) of a vertex.
      Specified by:
      degree in interface Graph<V>
      Parameters:
      vertex - the vertex
      Returns:
      degree of vertex
    • isDirected

      public boolean isDirected()
      Description copied from interface: Graph
      Checks if this graph is directed.
      Specified by:
      isDirected in interface Graph<V>
      Returns:
      true if directed, false if undirected