next up previous contents
Next: SimpleGraph Class Up: GraphStuff Package Previous: Interaction with Outside Objects

SimpleUndirectedGraph Class

The SimpleUndirectedGraph class extends the SimpleGraph class and as such provides very little functionality. In particular, the SimpleUndirectedGraph class provides put(), get(), delete(), and isEdge() methods which treat a tex2html_wrap_inline1022 Edge the same as a tex2html_wrap_inline1024 Edge. It also insures that Edge objects are flagged as undirected, so that they display themselves properly.

package GraphStuff;

public class SimpleUndirectedGraph extends SimpleGraph {

   public SimpleUndirectedGraph(Edge[] E, Vertex[] V) { super(E,V); }

   public SimpleUndirectedGraph() {super();}

   public String toString() { 
      return "SimpleUndirectedGraph: " + stringRep();
   }

   public static Graph fromString(String str) {
      Vertex[] V;
      int i;
      if (-1==str.indexOf("SimpleUndirectedGraph:")
          || null==(V = Vertex.arrayFromString(str)) )
         return null;
      return new SimpleUndirectedGraph(Edge.arrayFromString(str),V);
   }

   public Graph put(int u,int v,Edge E) { 
      super.delete(v,u);
      return super.put(u,v,E.directed(false));  
   }

   public Edge get(int u,int v){
      Edge E=super.get(u,v);
      if (E!=null) 
         return E;
      return super.get(v,u);
   }

   public Graph delete(int u,int v){
      super.delete(v,u);
      super.delete(u,v);
      return this;
   }

   public boolean isEdge(int u, int v) {
      return super.isEdge(u,v) || super.isEdge(v,u);
   }

}



Kelly Waters
Mon Oct 27 18:18:15 EST 1997