forked from Pedro-Bautista/GraphADT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjectEdge.h
77 lines (57 loc) · 1.5 KB
/
ObjectEdge.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Created by Ken V on 4/16/23.
//
#ifndef GRAPHADT_OBJECTEDGE_H
#define GRAPHADT_OBJECTEDGE_H
#include "ObjectVertex.h"
template<typename G>
class ObjectEdge{
public:
G value;
std::list<ObjectVertex<G>> incidentList;
//constructors
explicit ObjectEdge(G value) : value(value) {}
ObjectEdge() {}
public:
//returns the element of the label
G operator*();
//add Vertex to edge
void addVertex(ObjectVertex<G> v) {
incidentList.push_back(v);
}
//returns the vertex list of the edges ends
std::list<ObjectVertex<G>> endVertices();
//test whether this edge and f are adjacent
bool isAdjacentTo(ObjectVertex<G> f);
//test whether edge is incident on v
bool IsIncidentOn(ObjectVertex<G> V);
friend class ObjectVertex<G>;
};
template<typename G>
std::list<ObjectVertex<G>> ObjectEdge<G>::endVertices() {
return incidentList;
}
template<typename G>
bool ObjectEdge<G>::IsIncidentOn(ObjectVertex <G> V) {
for (auto x = incidentList.begin(); x != incidentList.end(); ++x) {
if (*x == V) {
return true;
}
}
return false;
}
template<typename G>
bool ObjectEdge<G>::isAdjacentTo(ObjectVertex<G> f) {
std::list<ObjectVertex<std::string>>::iterator i;
for (i = incidentList.begin(); i != incidentList.end(); ++i) {
if (**i == *f) {
return true;
}
}
return false;
}
template<typename G>
G ObjectEdge<G>::operator*() {
return value;
}
#endif //GRAPHADT_OBJECTEDGE_H