Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

Edge.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 
36 namespace ogdf {
37 namespace energybased {
38 namespace fmmm {
39 
42 class Edge
43 {
44 
46  friend ostream &operator<< (ostream & output, const Edge & E)
47  {
48  output <<"edge_index " << E.e->index() << " Graph_ptr " << E.Graph_ptr << " angle"
49  << E.angle << " cut vertex " << E.cut_vertex->index();
50  return output;
51  }
52 
53 #if 0
54  friend istream &operator>> (istream & input, Edge & E)
56  {
57  input >> E;//.e>>E.Graph_ptr;
58  return input;
59  }
60 #endif
61 
62 public:
64  Edge() {
65  e = nullptr;
66  Graph_ptr = nullptr;
67  angle = 0;
68  cut_vertex = nullptr;
69  }
70 
71  ~Edge() { }
72 
73  void set_Edge (edge f,Graph* g_ptr) {
74  Graph_ptr = g_ptr;
75  e = f;
76  }
77 
78  void set_Edge(edge f,double i,node c) {
79  angle = i;
80  e = f;
81  cut_vertex = c;
82  }
83 
84  Graph* get_Graph_ptr() const { return Graph_ptr; }
85  edge get_edge() const { return e; }
86  double get_angle() const { return angle; }
87  node get_cut_vertex() const { return cut_vertex; }
88 
89 private:
92  double angle;
94 };
95 
96 
97 class EdgeMaxBucketFunc : public BucketFunc<Edge>
98 {
99 public:
101 
102  int getBucket(const Edge& E) override { return get_max_index(E); }
103 
104 private:
106  int get_max_index(const Edge& E) {
107  int source_index = E.get_edge()->source()->index();
108  int target_index = E.get_edge()->target()->index();
109  OGDF_ASSERT(source_index != target_index); // no self-loop
110  if(source_index < target_index) {
111  return target_index;
112  } else {
113  return source_index;
114  }
115  }
116 };
117 
118 
119 class EdgeMinBucketFunc : public BucketFunc<Edge>
120 {
121 public:
123 
124  int getBucket(const Edge& E) override { return get_min_index(E); }
125 
126 private:
127 
129  int get_min_index(const Edge& E)
130  {
131  int source_index = E.get_edge()->source()->index();
132  int target_index = E.get_edge()->target()->index();
133  OGDF_ASSERT(source_index != target_index); // no self-loop
134  if (source_index < target_index) {
135  return source_index;
136  } else {
137  return target_index;
138  }
139  }
140 };
141 
142 }
143 }
144 }
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:327
int getBucket(const Edge &E) override
Definition: Edge.h:124
~Edge()
destructor
Definition: Edge.h:71
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
static std::istream & operator>>(std::istream &inStream, HyperGraph::NodeArray< T > &array)
Definition: HyperGraph.h:814
int getBucket(const Edge &E) override
Definition: Edge.h:102
int index() const
Returns the index of the edge.
Definition: Graph_d.h:323
helping data structure for deleting parallel edges in class FMMMLayout and Multilevel (needed for the...
Definition: Edge.h:42
node get_cut_vertex() const
Definition: Edge.h:87
int get_min_index(const Edge &E)
returns the minimum index of e
Definition: Edge.h:129
friend ostream & operator<<(ostream &output, const Edge &E)
outputstream for Edge
Definition: Edge.h:46
edge get_edge() const
Definition: Edge.h:85
void set_Edge(edge f, double i, node c)
Definition: Edge.h:78
Class for the representation of edges.
Definition: Graph_d.h:291
Class for the representation of nodes.
Definition: Graph_d.h:167
Abstract base class for bucket functions.
Definition: basic.h:255
Graph * get_Graph_ptr() const
Definition: Edge.h:84
Includes declaration of graph class.
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:201
double get_angle() const
Definition: Edge.h:86
int get_max_index(const Edge &E)
returns the maximum index of e
Definition: Edge.h:106
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:325
The namespace for all OGDF objects.
Edge()
constructor
Definition: Edge.h:64
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
void set_Edge(edge f, Graph *g_ptr)
Definition: Edge.h:73