public AdjacencyListWeightedDirectedGraph<WeightedEdge> readDIMACSGraph
		(InputStream in) throws IOException, IllegalArgumentException {
		
		// nothing read yet
		String s = "";
		
		// the byte most recently read from the input stream
		int i;
		
		// read everything from the input stream
		while ((i = in.read()) != -1) {
			// get the read character
			char c = (char)i;
			
			if (c == '\r' || c == '\n') {
				// end of line - check the line type
				if (s.startsWith("c")) {
					if (s.length() > 1) {
						readComment(s.substring(2));
					}
				} else if (s.startsWith("p")) {
					readProblemLine(s.substring(2));
				} else if (s.startsWith("a")) {
					readArcDescriptor(s.substring(2));
				}
				
				// empty buffer
				s = "";
			} else {
				// buffer the read character until the end of the line
				s += c;
			}
		}
		
		return graph;
	}