From 5db213ed03e062cfdbfbe5fc74a0e8dd4b14ad09 Mon Sep 17 00:00:00 2001 From: mac76tib2 <956269333@qq.com> Date: Mon, 3 Jul 2023 15:57:31 +0800 Subject: [PATCH] ADD file via upload --- main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..67b1c9c --- /dev/null +++ b/main.cpp @@ -0,0 +1,36 @@ +#include +#include +using namespace std; + +#include "algraph.h" + +struct Station { + string name; + int line1; + int line2; +}; + +ALGraph 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("东安路")); + +} \ No newline at end of file