Class DefaultGraph

java.lang.Object
edu.uci.ics.jung.graph.AbstractGraph<V,​E>
edu.uci.ics.jung.graph.SparseGraph<AbstractGraphNode,​AbstractGraphEdge>
mgui.interfaces.graphs.InterfaceAbstractGraph
mgui.interfaces.graphs.DefaultGraph
All Implemented Interfaces:
edu.uci.ics.jung.graph.Graph<AbstractGraphNode,​AbstractGraphEdge>, edu.uci.ics.jung.graph.Hypergraph<AbstractGraphNode,​AbstractGraphEdge>, java.io.Serializable, NetworkGraphListener, AttributeListener, AttributeObject, InterfaceObject, PopupMenuObject, NamedObject, TreeObject, CleanableObject, XMLObject, IconObject
Direct Known Subclasses:
AbstractNetworkGraph

public class DefaultGraph
extends InterfaceAbstractGraph
Default implementation of a Graph in ModelGUI. Nodes are associated with unique labels.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • DefaultGraph

      public DefaultGraph()
    • DefaultGraph

      public DefaultGraph​(java.lang.String name)
    • DefaultGraph

      public DefaultGraph​(InterfaceAbstractGraph graph)
      Construct a new graph as a copy of graph.
      Parameters:
      graph -
  • Method Details

    • addVertex

      public boolean addVertex​(AbstractGraphNode vertex)
      Specified by:
      addVertex in interface edu.uci.ics.jung.graph.Hypergraph<AbstractGraphNode,​AbstractGraphEdge>
      Overrides:
      addVertex in class edu.uci.ics.jung.graph.SparseGraph<AbstractGraphNode,​AbstractGraphEdge>
    • clone

      public java.lang.Object clone() throws java.lang.CloneNotSupportedException
      Overrides:
      clone in class InterfaceAbstractGraph
      Throws:
      java.lang.CloneNotSupportedException
    • getTreeLabel

      public java.lang.String getTreeLabel()
      Description copied from interface: TreeObject
      Returns the label text to appear in a tree node.
      Specified by:
      getTreeLabel in interface TreeObject
      Overrides:
      getTreeLabel in class InterfaceAbstractGraph
      Returns:
    • addGraphNode

      public boolean addGraphNode​(AbstractGraphNode node)
      Adds a node to this graph. Returns true if the node was added; returns false if it (or a node of the same label) already exists.
      Parameters:
      node -
      Returns:
    • removeGraphNode

      public boolean removeGraphNode​(java.lang.String label)
      Removes the node corresponding to label. Returns true if it was removed; false if it was not found.
      Parameters:
      label -
      Returns:
    • removeGraphNode

      public boolean removeGraphNode​(AbstractGraphNode node)
      Removes the given node. Returns true if it was removed; false if it was not found.
      Parameters:
      label -
      Returns:
    • addGraphEdge

      public boolean addGraphEdge​(AbstractGraphEdge edge)
      Adds an edge to this graph. The endpoints of the edge must exists as nodes in this graph; otherwise, this method returns false.
      Parameters:
      edge -
      Returns:
      true is edge was added; false otherwise
    • addGraphEdge

      public boolean addGraphEdge​(AbstractGraphEdge edge, edu.uci.ics.jung.graph.util.EdgeType type)
      Adds an edge to this graph. The endpoints of the edge must exists as nodes in this graph; otherwise, this method returns false.
      Parameters:
      edge -
      Returns:
      true is edge was added; false otherwise
    • removeGraphEdge

      public boolean removeGraphEdge​(AbstractGraphEdge edge)
      Removes the given graph edge. Returns true if it was removed successfully; false otherwise.
      Parameters:
      edge -
      Returns:
    • getVertexByLabel

      public AbstractGraphNode getVertexByLabel​(java.lang.String label)
      Returns the node corresponding to label. Returns null if there is no corresponding label.
      Parameters:
      label -
      Returns:
      The node corresponding to label
    • setFromGraph

      protected void setFromGraph​(InterfaceAbstractGraph g)
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu()
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Overrides:
      getPopupMenu in class InterfaceAbstractGraph
      Returns:
    • handlePopupEvent

      public void handlePopupEvent​(java.awt.event.ActionEvent e)
      Description copied from interface: PopupMenuObject
      Handles an event on this object's popup menu.
      Specified by:
      handlePopupEvent in interface PopupMenuObject
      Overrides:
      handlePopupEvent in class InterfaceAbstractGraph
    • showPopupMenu

      public void showPopupMenu​(java.awt.event.MouseEvent e)
      Description copied from interface: PopupMenuObject
      Shows a popup menu at the point of the given MouseEvent.
      Specified by:
      showPopupMenu in interface PopupMenuObject
      Overrides:
      showPopupMenu in class InterfaceAbstractGraph