You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
712 B
36 lines
712 B
1 year ago
|
#include <iostream>
|
||
|
#include <string>
|
||
|
using namespace std;
|
||
|
|
||
|
#include "algraph.h"
|
||
|
|
||
|
struct Station {
|
||
|
string name;
|
||
|
int line1;
|
||
|
int line2;
|
||
|
};
|
||
|
|
||
|
ALGraph<Station, int, 1024> G;
|
||
|
|
||
|
int FindVertex(string name)
|
||
|
{
|
||
|
for (int i = 0; i < G.vexnum; i++)
|
||
|
if (G.vexs[i].data.name == name)
|
||
|
return i;
|
||
|
return -1; // not found
|
||
|
}
|
||
|
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
InitGraph(G);
|
||
|
|
||
|
AddVertex(G, Station{"肇嘉浜路", 1});
|
||
|
AddVertex(G, Station{"东安路", 1});
|
||
|
AddVertex(G, Station{"上海体育场", 1});
|
||
|
AddVertex(G, Station{"嘉善路", 1});
|
||
|
AddVertex(G, Station{"大木桥路", 1});
|
||
|
|
||
|
AddEdge(G, FindVertex("肇嘉浜路"), FindVertex("东安路"));
|
||
|
|
||
|
}
|