Removed DOCUMENT ME comments that were generated and applied source code
[utils] / system / general / src / main / java / org / wamblee / system / graph / Graph.java
index f84873e3ee0b0a761223a060f91a5ccae08bd138..f26af1c7dbaaffd643117688d4246442922d3992 100644 (file)
@@ -19,43 +19,38 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-
 /**
  * Represents a graph consisting of nodes and edges.
- *
+ * 
  * @author Erik Brakkee
  */
 public class Graph {
-    /**
-     * DOCUMENT ME!
-     */
     private List<Node> nodes;
 
-    /**
-     * DOCUMENT ME!
-     */
     private List<Edge> edges;
 
-/**
+    /**
      * Constructs the graph.
      */
     public Graph() {
-        nodes     = new ArrayList<Node>();
-        edges     = new ArrayList<Edge>();
+        nodes = new ArrayList<Node>();
+        edges = new ArrayList<Edge>();
     }
 
     /**
      * Adds a node.
-     *
-     * @param aNode Node to add.
-     *
-     * @throws IllegalArgumentException In case the node already exists. Node
-     *         equality is checked using <code>equals</code>.
+     * 
+     * @param aNode
+     *            Node to add.
+     * 
+     * @throws IllegalArgumentException
+     *             In case the node already exists. Node equality is checked
+     *             using <code>equals</code>.
      */
     public void addNode(Node aNode) {
         if (nodes.contains(aNode)) {
-            throw new IllegalArgumentException("Node '" + aNode.getName()
-                "' already exists");
+            throw new IllegalArgumentException("Node '" + aNode.getName() +
+                "' already exists");
         }
 
         nodes.add(aNode);
@@ -63,9 +58,10 @@ public class Graph {
 
     /**
      * Finds a node with the given name.
-     *
-     * @param aName Node name.
-     *
+     * 
+     * @param aName
+     *            Node name.
+     * 
      * @return Node or null if not found.
      */
     public Node findNode(String aName) {
@@ -80,19 +76,20 @@ public class Graph {
 
     /**
      * Removes a node.
-     *
-     * @param aNode Node to remove.
-     *
+     * 
+     * @param aNode
+     *            Node to remove.
+     * 
      * @return True iff the node was removed.
-     *
-     * @throws IllegalArgumentException In case there are edges of which the
-     *         node is a part.
+     * 
+     * @throws IllegalArgumentException
+     *             In case there are edges of which the node is a part.
      */
     public boolean removeNode(Node aNode) {
         if (!findOutgoing(aNode).isEmpty() || !findIncoming(aNode).isEmpty()) {
-            throw new IllegalArgumentException("Cannot remove node '"
-                + aNode.getName()
-                "' because it is connected to one or more edges");
+            throw new IllegalArgumentException("Cannot remove node '" +
+                aNode.getName() +
+                "' because it is connected to one or more edges");
         }
 
         return nodes.remove(aNode);
@@ -100,9 +97,10 @@ public class Graph {
 
     /**
      * Adds a list of nodes.
-     *
-     * @param aNodes Nodes to add.
-     *
+     * 
+     * @param aNodes
+     *            Nodes to add.
+     * 
      * @see #addNode(Node)
      */
     public void addNodes(List<Node> aNodes) {
@@ -113,27 +111,29 @@ public class Graph {
 
     /**
      * Adds an edge.
-     *
-     * @param aEdge Edge to add.
-     *
-     * @throws IllegalArgumentException In case one of the nodes of the edges
-     *         is not part of the graph or if the same edge (as determined by
-     *         {@link #equals(Object)} is already a part of the graph.
+     * 
+     * @param aEdge
+     *            Edge to add.
+     * 
+     * @throws IllegalArgumentException
+     *             In case one of the nodes of the edges is not part of the
+     *             graph or if the same edge (as determined by
+     *             {@link #equals(Object)} is already a part of the graph.
      */
     public void addEdge(Edge aEdge) {
         if (edges.contains(aEdge)) {
-            throw new IllegalArgumentException("Edge '" + aEdge
-                "' already exists");
+            throw new IllegalArgumentException("Edge '" + aEdge +
+                "' already exists");
         }
 
         if (!nodes.contains(aEdge.getFrom())) {
-            throw new IllegalArgumentException("From node '" + aEdge.getFrom()
-                "' from edge '" + aEdge + "' is not part of the graph");
+            throw new IllegalArgumentException("From node '" + aEdge.getFrom() +
+                "' from edge '" + aEdge + "' is not part of the graph");
         }
 
         if (!nodes.contains(aEdge.getTo())) {
-            throw new IllegalArgumentException("To node '" + aEdge.getTo()
-                "' from edge '" + aEdge + "' is not part of the graph");
+            throw new IllegalArgumentException("To node '" + aEdge.getTo() +
+                "' from edge '" + aEdge + "' is not part of the graph");
         }
 
         edges.add(aEdge);
@@ -141,9 +141,10 @@ public class Graph {
 
     /**
      * Removes an edge.
-     *
-     * @param aEdge Edge to remove.
-     *
+     * 
+     * @param aEdge
+     *            Edge to remove.
+     * 
      * @return True if the edge was removed.
      */
     public boolean removeEdge(Edge aEdge) {
@@ -152,8 +153,9 @@ public class Graph {
 
     /**
      * Adds a number of edges.
-     *
-     * @param aEdges Edges to add.
+     * 
+     * @param aEdges
+     *            Edges to add.
      */
     public void addEdges(List<Edge> aEdges) {
         for (Edge edge : aEdges) {
@@ -163,7 +165,7 @@ public class Graph {
 
     /**
      * Gets the nodes.
-     *
+     * 
      * @return Copy of the list of nodes of the graph.
      */
     public List<Node> getNodes() {
@@ -172,7 +174,7 @@ public class Graph {
 
     /**
      * Gets the edges.
-     *
+     * 
      * @return Copy of the list of edges of the graph.
      */
     public List<Edge> getEdges() {
@@ -180,11 +182,11 @@ public class Graph {
     }
 
     /**
-     * Extends the graph with edges using an edge factory. All
-     * combinations of  nodes are passed to the factory which creates
-     * additional edges.
-     *
-     * @param aFactory Edge factory.
+     * Extends the graph with edges using an edge factory. All combinations of
+     * nodes are passed to the factory which creates additional edges.
+     * 
+     * @param aFactory
+     *            Edge factory.
      */
     public void extend(EdgeFactory aFactory) {
         for (Node from : nodes) {
@@ -196,8 +198,9 @@ public class Graph {
 
     /**
      * Applies a filter to the graph for removing elements.
-     *
-     * @param aFilter Filter to apply.
+     * 
+     * @param aFilter
+     *            Filter to apply.
      */
     public void applyFilter(EdgeFilter aFilter) {
         for (Iterator<Edge> edge = edges.iterator(); edge.hasNext();) {
@@ -208,12 +211,13 @@ public class Graph {
     }
 
     /**
-     * Finds all outgoing edges of a node. More specifically, finds
-     * all edges <code>e</code> for which <code>e.getFrom().getName() =
+     * Finds all outgoing edges of a node. More specifically, finds all edges
+     * <code>e</code> for which <code>e.getFrom().getName() =
      * aNode.getName()</code>.
-     *
-     * @param aNode Node for which to find outgoing edges.
-     *
+     * 
+     * @param aNode
+     *            Node for which to find outgoing edges.
+     * 
      * @return List of outgoing edges.
      */
     public List<Edge> findOutgoing(Node aNode) {
@@ -229,12 +233,13 @@ public class Graph {
     }
 
     /**
-     * Finds all incoming edges of a node.  More specifically, finds
-     * all edges <code>e</code> for which <code>e.getTo().getName() =
+     * Finds all incoming edges of a node. More specifically, finds all edges
+     * <code>e</code> for which <code>e.getTo().getName() =
      * aNode.getName()</code>.
-     *
-     * @param aNode Node for which to find incoming edges.
-     *
+     * 
+     * @param aNode
+     *            Node for which to find incoming edges.
+     * 
      * @return List of incoming edges.
      */
     public List<Edge> findIncoming(Node aNode) {
@@ -250,15 +255,16 @@ public class Graph {
     }
 
     /**
-     * Implements a visitor design pattern. This loops over all nodes
-     * and all edges and invokes the appropriate visit methods on the visitor.
-     *
-     * @param aVisitor Visitor.
+     * Implements a visitor design pattern. This loops over all nodes and all
+     * edges and invokes the appropriate visit methods on the visitor.
+     * 
+     * @param aVisitor
+     *            Visitor.
      */
     public void accept(Visitor aVisitor) {
         List<Node> nodes = getNodes(); // copy to make sure the visitor can
-                                       // modify the
-                                       // list of nodes as part of the loop.
+        // modify the
+        // list of nodes as part of the loop.
 
         List<Edge> edges = getEdges(); // copy ..... (see above).