lab_graphs
Gangnam-Style Graphs
edge.h
Go to the documentation of this file.
1 
6 #ifndef _EDGE_H_
7 #define _EDGE_H_
8 
9 #include <string>
10 #include <limits.h>
11 
12 using std::string;
13 
14 typedef size_t Vertex;
15 
22 class Edge
23 {
24  public:
25 
26  Vertex source;
27  Vertex dest;
28  int weight;
29  string label;
30 
37  Edge(Vertex u, Vertex v, string lbl) :
38  source(u), dest(v), weight(-1), label(lbl) { /* nothing */ }
39 
47  Edge(Vertex u, Vertex v, int w, string lbl) :
48  source(u), dest(v), weight(w), label(lbl) { /* nothing */ }
49 
53  Edge() :
54  source(-1), dest(-1), weight(-1), label("") { /* nothing */ }
55 
62  bool operator<(const Edge & other) const
63  {
64  return weight < other.weight;
65  }
66 };
67 
68 #endif
Represents an edge in a graph; used by the Graph class.
Definition: edge.h:22
Edge()
Default constructor.
Definition: edge.h:53
Edge(Vertex u, Vertex v, string lbl)
Parameter constructor for unweighted graphs.
Definition: edge.h:37
Edge(Vertex u, Vertex v, int w, string lbl)
Parameter constructor for weighted graphs.
Definition: edge.h:47
bool operator<(const Edge &other) const
Compares two Edges.
Definition: edge.h:62