Class MolecularGraph

java.lang.Object
org.episteme.natural.chemistry.MolecularGraph
All Implemented Interfaces:
Graph<Atom>

public class MolecularGraph extends Object implements Graph<Atom>
Represents a molecule as a graph of atoms and bonds.

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • MolecularGraph

      public MolecularGraph()
  • Method Details

    • addAtom

      public void addAtom(Atom atom)
    • addBond

      public void addBond(Atom a, Atom b, MolecularGraph.BondType type)
    • getAtoms

      public List<Atom> getAtoms()
    • getBonds

      public List<MolecularGraph.Bond> getBonds()
    • getConnections

      public Map<Atom, List<MolecularGraph.Bond>> getConnections()
      connection table: Mapinvalid input: '<'Atom, List>
    • getMolecularMass

      public double getMolecularMass()
      Calculates molecular mass.
    • getFormula

      public String getFormula()
      Returns the formula (e.g. C6H6).
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • vertices

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

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

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

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

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

      public int degree(Atom vertex)
      Description copied from interface: Graph
      Returns the degree (number of edges) of a vertex.
      Specified by:
      degree in interface Graph<Atom>
      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<Atom>
      Returns:
      true if directed, false if undirected
    • vertexCount

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