Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ebicochineal committed Mar 4, 2024
1 parent 2f0f0d9 commit 6338eca
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 56 deletions.
30 changes: 22 additions & 8 deletions E512W3DUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,22 @@ class E512PriorityQueueMax {
}
};

struct GraphEdge {
struct E512Edge {
public:
int a, b, cost;
GraphEdge () {
E512Edge () {
this->a = 0;
this->b = 0;
this->cost = 1000000;
}
GraphEdge (int a, int b, int cost) {
E512Edge (int a, int b, int cost) {
this->a = a;
this->b = b;
this->cost = cost;
}
bool operator == (const GraphEdge& t) const { return this->a == t.a && this->b == t.b; }
bool operator == (const E512Edge& t) const { return this->a == t.a && this->b == t.b; }
};
class GraphDijkstra {
class E512GraphDijkstra {
private:
class Node {
public:
Expand All @@ -397,9 +397,9 @@ class GraphDijkstra {
E512Array<int> rpath;
int pathcost;

GraphDijkstra () {}
E512GraphDijkstra () {}

GraphDijkstra (int n, E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (int n, E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
this->n = n;
Expand All @@ -417,7 +417,7 @@ class GraphDijkstra {
}
}

GraphDijkstra (E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
int n = 0;
Expand All @@ -436,6 +436,20 @@ class GraphDijkstra {
}
}

void costUpdate (E512Array<E512Edge>& edges, bool undir = false) {
for (auto&& i : this->edgecost) { i.clear(); }
if (undir) {// undirected
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
this->edgecost[i.b].emplace_back(i.a, i.cost);
}
} else {// directed
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
}
}
}

void calcPath (int start_i, int end_i) {
this->path.clear();
this->rpath.clear();
Expand Down
30 changes: 22 additions & 8 deletions examples/example1/E512W3DUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,22 @@ class E512PriorityQueueMax {
}
};

struct GraphEdge {
struct E512Edge {
public:
int a, b, cost;
GraphEdge () {
E512Edge () {
this->a = 0;
this->b = 0;
this->cost = 1000000;
}
GraphEdge (int a, int b, int cost) {
E512Edge (int a, int b, int cost) {
this->a = a;
this->b = b;
this->cost = cost;
}
bool operator == (const GraphEdge& t) const { return this->a == t.a && this->b == t.b; }
bool operator == (const E512Edge& t) const { return this->a == t.a && this->b == t.b; }
};
class GraphDijkstra {
class E512GraphDijkstra {
private:
class Node {
public:
Expand All @@ -397,9 +397,9 @@ class GraphDijkstra {
E512Array<int> rpath;
int pathcost;

GraphDijkstra () {}
E512GraphDijkstra () {}

GraphDijkstra (int n, E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (int n, E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
this->n = n;
Expand All @@ -417,7 +417,7 @@ class GraphDijkstra {
}
}

GraphDijkstra (E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
int n = 0;
Expand All @@ -436,6 +436,20 @@ class GraphDijkstra {
}
}

void costUpdate (E512Array<E512Edge>& edges, bool undir = false) {
for (auto&& i : this->edgecost) { i.clear(); }
if (undir) {// undirected
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
this->edgecost[i.b].emplace_back(i.a, i.cost);
}
} else {// directed
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
}
}
}

void calcPath (int start_i, int end_i) {
this->path.clear();
this->rpath.clear();
Expand Down
30 changes: 22 additions & 8 deletions examples/example2/E512W3DUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,22 @@ class E512PriorityQueueMax {
}
};

struct GraphEdge {
struct E512Edge {
public:
int a, b, cost;
GraphEdge () {
E512Edge () {
this->a = 0;
this->b = 0;
this->cost = 1000000;
}
GraphEdge (int a, int b, int cost) {
E512Edge (int a, int b, int cost) {
this->a = a;
this->b = b;
this->cost = cost;
}
bool operator == (const GraphEdge& t) const { return this->a == t.a && this->b == t.b; }
bool operator == (const E512Edge& t) const { return this->a == t.a && this->b == t.b; }
};
class GraphDijkstra {
class E512GraphDijkstra {
private:
class Node {
public:
Expand All @@ -397,9 +397,9 @@ class GraphDijkstra {
E512Array<int> rpath;
int pathcost;

GraphDijkstra () {}
E512GraphDijkstra () {}

GraphDijkstra (int n, E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (int n, E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
this->n = n;
Expand All @@ -417,7 +417,7 @@ class GraphDijkstra {
}
}

GraphDijkstra (E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
int n = 0;
Expand All @@ -436,6 +436,20 @@ class GraphDijkstra {
}
}

void costUpdate (E512Array<E512Edge>& edges, bool undir = false) {
for (auto&& i : this->edgecost) { i.clear(); }
if (undir) {// undirected
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
this->edgecost[i.b].emplace_back(i.a, i.cost);
}
} else {// directed
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
}
}
}

void calcPath (int start_i, int end_i) {
this->path.clear();
this->rpath.clear();
Expand Down
30 changes: 22 additions & 8 deletions examples/example3/E512W3DUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,22 @@ class E512PriorityQueueMax {
}
};

struct GraphEdge {
struct E512Edge {
public:
int a, b, cost;
GraphEdge () {
E512Edge () {
this->a = 0;
this->b = 0;
this->cost = 1000000;
}
GraphEdge (int a, int b, int cost) {
E512Edge (int a, int b, int cost) {
this->a = a;
this->b = b;
this->cost = cost;
}
bool operator == (const GraphEdge& t) const { return this->a == t.a && this->b == t.b; }
bool operator == (const E512Edge& t) const { return this->a == t.a && this->b == t.b; }
};
class GraphDijkstra {
class E512GraphDijkstra {
private:
class Node {
public:
Expand All @@ -397,9 +397,9 @@ class GraphDijkstra {
E512Array<int> rpath;
int pathcost;

GraphDijkstra () {}
E512GraphDijkstra () {}

GraphDijkstra (int n, E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (int n, E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
this->n = n;
Expand All @@ -417,7 +417,7 @@ class GraphDijkstra {
}
}

GraphDijkstra (E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
int n = 0;
Expand All @@ -436,6 +436,20 @@ class GraphDijkstra {
}
}

void costUpdate (E512Array<E512Edge>& edges, bool undir = false) {
for (auto&& i : this->edgecost) { i.clear(); }
if (undir) {// undirected
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
this->edgecost[i.b].emplace_back(i.a, i.cost);
}
} else {// directed
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
}
}
}

void calcPath (int start_i, int end_i) {
this->path.clear();
this->rpath.clear();
Expand Down
30 changes: 22 additions & 8 deletions examples/example4/E512W3DUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,22 @@ class E512PriorityQueueMax {
}
};

struct GraphEdge {
struct E512Edge {
public:
int a, b, cost;
GraphEdge () {
E512Edge () {
this->a = 0;
this->b = 0;
this->cost = 1000000;
}
GraphEdge (int a, int b, int cost) {
E512Edge (int a, int b, int cost) {
this->a = a;
this->b = b;
this->cost = cost;
}
bool operator == (const GraphEdge& t) const { return this->a == t.a && this->b == t.b; }
bool operator == (const E512Edge& t) const { return this->a == t.a && this->b == t.b; }
};
class GraphDijkstra {
class E512GraphDijkstra {
private:
class Node {
public:
Expand All @@ -397,9 +397,9 @@ class GraphDijkstra {
E512Array<int> rpath;
int pathcost;

GraphDijkstra () {}
E512GraphDijkstra () {}

GraphDijkstra (int n, E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (int n, E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
this->n = n;
Expand All @@ -417,7 +417,7 @@ class GraphDijkstra {
}
}

GraphDijkstra (E512Array<GraphEdge> edges, bool undir = false) {
E512GraphDijkstra (E512Array<E512Edge>& edges, bool undir = false) {
this->pathcost = 0;
this->path.clear();
int n = 0;
Expand All @@ -436,6 +436,20 @@ class GraphDijkstra {
}
}

void costUpdate (E512Array<E512Edge>& edges, bool undir = false) {
for (auto&& i : this->edgecost) { i.clear(); }
if (undir) {// undirected
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
this->edgecost[i.b].emplace_back(i.a, i.cost);
}
} else {// directed
for (auto&& i : edges) {
this->edgecost[i.a].emplace_back(i.b, i.cost);
}
}
}

void calcPath (int start_i, int end_i) {
this->path.clear();
this->rpath.clear();
Expand Down
Loading

0 comments on commit 6338eca

Please sign in to comment.