ps3xmlgraph

ps3xmlgraph - / Read a Graph from XML File import...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// Read a Graph from XML File import java.io.*; import java.net.*; import java.util.*; import mit16_410_13.*; class Ps3XMLGraph { Hashtable vertices; Ps3XMLGraph () { vertices = new Hashtable(); } public Dictionary readGraph (String path) { XMLStream strm; FileInputStream istrm=null; try { Ps3Vertex currentVertex=null; boolean ingraph=false; istrm=new FileInputStream(path); strm=new XMLStream(istrm, System.out); System.out.println("Reading from "+path); String txt=strm.readText(); // Read any preceding text for (XMLTag atag=strm.readNextTag(); atag!=null; atag=strm.readNextTag()) { String tagid=atag.getTagID(); if (tagid.equals("GRAPH")) { if (ingraph) System.out.println("Nested GRAPH not allowed\n"); ingraph=true; } else if (tagid.equals("/GRAPH")) { if (ingraph) ingraph=false; else System.out.println("/GRAPH not in a GRAPH"); } else if (tagid.equals("VERTEX")) { if (!ingraph) { System.out.println("VERTEX not in a GRAPH"); ingraph=true; // recover } double x=new Double(atag.getAttribute("x")).doubleValue();
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/07/2011 for the course AERO 16.410 taught by Professor Brianwilliams during the Fall '05 term at MIT.

Page1 / 2

ps3xmlgraph - / Read a Graph from XML File import...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online