Changes for William's Analysis
[IRC.git] / Robust / src / Util / GraphNode.java
index cbe96016d860db9de7fc46ac2dea65a989419b01..c352aaa4af8c680b3ae9e26c5c97130ab6fee0c6 100755 (executable)
@@ -9,7 +9,7 @@ public class GraphNode {
     public static final NodeStatus UNVISITED = new NodeStatus("UNVISITED");
     public static final NodeStatus PROCESSING = new NodeStatus("PROCESSING");
     public static final NodeStatus FINISHED = new NodeStatus("FINISHED");
-
+    
     public static class NodeStatus {
         private static String name;
         private NodeStatus(String name) { this.name = name; }
@@ -77,10 +77,10 @@ public class GraphNode {
         if (param == null) {
             throw new NullPointerException();
         }
-        if (param.length() > 0) {
-            dotnodeparams = "," + param;
+        if (dotnodeparams.length() > 0) {
+            dotnodeparams += "," + param;
         } else {
-            dotnodeparams = new String();
+            dotnodeparams = param;
         }
     }
 
@@ -90,7 +90,7 @@ public class GraphNode {
         }
         this.status = status;
     }
-
+       
     public String getLabel() {
        return "";
     }
@@ -98,6 +98,10 @@ public class GraphNode {
     public String getTextLabel() {
        return "";
     }
+    
+       public String getName(){
+               return "";
+       }
 
     public NodeStatus getStatus() {
         return this.status;
@@ -119,6 +123,14 @@ public class GraphNode {
        return (Edge) inedges.get(i);
     }
 
+    public Vector getEdgeVector() {
+       return edges;
+    }
+
+    public Vector getInedgeVector() {
+       return inedges;
+    }
+
     public Iterator edges() {
         return edges.iterator();
     }
@@ -126,7 +138,7 @@ public class GraphNode {
     public Iterator inedges() {
         return inedges.iterator();
     }
-
+    
     public void addEdge(Edge newedge) {
        newedge.setSource(this);
         edges.addElement(newedge);
@@ -134,6 +146,26 @@ public class GraphNode {
        tonode.inedges.addElement(newedge);
     }
 
+    public void addEdge(Vector v) {
+       for (Iterator it = v.iterator(); it.hasNext();)
+           addEdge((Edge)it.next());
+    }
+
+    public void removeEdge(Edge edge) {
+       edges.remove(edge);
+    }
+
+    public void removeInedge(Edge edge) {
+       inedges.remove(edge);
+    }
+
+    public void removeAllEdges() {
+       edges.removeAllElements();
+    }
+
+    public void removeAllInedges() {
+       inedges.removeAllElements();
+    }
     void reset() {
            discoverytime = -1;
            finishingtime = -1;
@@ -207,10 +239,12 @@ public class GraphNode {
                          output.println("\tremincross=true;");*/
             output.println("\tnode [fontsize=10,height=\"0.1\", width=\"0.1\"];");
             output.println("\tedge [fontsize=6];");
-            traverse();
+           traverse();
             output.println("}\n");
         }
 
+
+
         private void traverse() {
            Set cycleset=GraphNode.findcycles(nodes);