parent
24e963eeef
commit
5db213ed03
@ -0,0 +1,36 @@
|
||||
#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("东安路"));
|
||||
|
||||
}
|
Loading…
Reference in new issue