2 //######################################################################################################################
4 #include "../include/edge.h"
8 using namespace LatticeGraph;
10 //######################################################################################################################
11 //#################################### Ceiling Cat & Basement Cat ###############################################
12 //######################################################################################################################
17 Edge::Edge() : uid(++suid){
20 Edge::Edge(std::weak_ptr<Node> n1, std::weak_ptr<Node> n2) : uid(++suid){
27 Edge::Edge(std::weak_ptr<Node> n1, std::weak_ptr<Node> n2, int dir, double weight) : uid(++suid){
30 this->direction = dir;
31 this->weight = weight;
34 //######################################################################################################################
35 //#################################### Get stuff ###############################################
36 //######################################################################################################################
39 * Returns UID of Edge.
41 unsigned int Edge::getUid(){
46 * Returns direction of Edge.
48 int Edge::getDirection(){
49 return this->direction;
52 * Get Node at index idx.
54 std::weak_ptr<Node> Edge::getVortex(int idx){
56 return (idx==0) ? n1 : n2;
58 catch(std::exception e){
59 return std::weak_ptr<Node>();
66 double Edge::getWeight(){
70 //######################################################################################################################
71 //#################################### Set stuff ###############################################
72 //######################################################################################################################
75 * Sets Edge direction for a directed graph.
77 void Edge::setDirection(int direction){
78 this->direction = direction;
81 * Sets Edge weight between nodes.
83 void Edge::setWeight(double weight){
84 this->weight = weight;
87 //######################################################################################################################
88 //#################################### Update stuff ###############################################
89 //######################################################################################################################
92 * Replaces Node n1 or n2 with new Node n_new.
94 void Edge::updateVortex(int idx, std::weak_ptr<Node> n_new ){
103 //######################################################################################################################
104 //#################################### Check stuff ###############################################
105 //######################################################################################################################
107 bool Edge::isMember(std::weak_ptr<Node> n){
108 return ( this->n1.lock()->getUid() == n.lock()->getUid() || this->n2.lock()->getUid() == n.lock()->getUid() ) ? true : false;
111 //######################################################################################################################