I'm trying to read data from file into a graph and am wondering if anyone could suggest the best way to go about this... The data will be presented with commented lines that need to be skipped - these lines will begin with "/". Once I've skipped the comment lines, I need to read each line, one word at a time.
My confusion is that if I read each line, in order to skip the commented lines, then I end up with an entire line in the buffer and would need to extract the words, one at a time. I have no idea how to do that. OR if I read each word, one at a time, then I skip the first word of the comment line, but read the rest of the words as if they're to be added to the graph.
Sample text file:
// An Example graph file
// Nodes are one-word strings.
// Edges are formatted as whitespace-delimited triples:
// sourceVertex destinationVertex edgeWeight
// By default, the graph is directed. An undirected
// graph is represented by including two equally weighted
// edges between every pair of connected vertices.
// The graph for Program 2 will be undirected and every
// pair of edges will be explicitly included in the file.
// The starting vertex is a one-word string corresponding
// to one of the nodes appearing in the Nodes: section.
// The keywords "Nodes:," "Edges:," and "Start:" are
// guaranteed to be unique in the file and will appear
// exactly as written here.
Atlanta Denver 1
Denver Atlanta 1
Atlanta Boston 1
Camloops Boston 1
Boston Atlanta 1
Boston Camloops 1