C++ Creating a Weighted Graph? -
How can I create a C ++ weighted graph where the graph has the weight of each head (some integer values)?
You can download your graph project:
Here is a function to create an article from the article data stored in a text file:
< Code> Zero GraphType :: CreateGraph () {ifstream infile; Four filename [50]; Int index Int vertex; Int adjacentVertex; If (gSize! = 0) ClearGraph (); Cout & lt; & Lt; "Enter input filename:"; Cin & gt; & Gt; file name; Cout & lt; & Lt; Endl; Infile.open (file name); If (! Infail) {cout & lt; & Lt; "Can not open input file." & Lt; & Lt; Endl; Return; } Infile & gt; & Gt; GSize; Graph = new anonymous linklist [GSI]; (Index = 0; index; & lt; gSize; index ++) {infile & gt; & Gt; Summit; Infile & gt; & Gt; AdjacentVertex; While (adjacentVertex! = -999) {article [top] .inertLast (adjacentVertex); Infile & gt; & Gt; AdjacentVertex; }} Infile.close (); }
and here is the article data (the number of lessons = 10, the top 0 to 9 and the adjacent coronation), from the text file "network 2.txt":
< P> 100 1 29-99 9
1 2-99 9
2 1 9 8 3-99 9
P> 3 2 8 5-99 9
4 3 8 6 5-99 9
5 4 6 7-9 9
6 4 7 8- 99 9
7 8 6 5-99 9
8 9 2 3 4 6 7-9 9
9 0 2 8-99 9
My question is how do I specify a specific value or weight from 0 to 9? Any help would be really appreciated in advance thanks!
(BGL) type, within which each edge and peak form a weight as a property See who prepares a guided graph with weighted edges.
Comments
Post a Comment