Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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 std::ostream &operator<< (std::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 std::istream &operator>> (std::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  void set_Edge (edge f,Graph* g_ptr) {
72  Graph_ptr = g_ptr;
73  e = f;
74  }
75 
76  void set_Edge(edge f,double i,node c) {
77  angle = i;
78  e = f;
79  cut_vertex = c;
80  }
81 
82  Graph* get_Graph_ptr() const { return Graph_ptr; }
83  edge get_edge() const { return e; }
84  double get_angle() const { return angle; }
85  node get_cut_vertex() const { return cut_vertex; }
86 
87 private:
90  double angle;
92 };
93 
94 
95 class EdgeMaxBucketFunc : public BucketFunc<Edge>
96 {
97 public:
99 
100  int getBucket(const Edge& E) override { return get_max_index(E); }
101 
102 private:
104  int get_max_index(const Edge& E) {
105  int source_index = E.get_edge()->source()->index();
106  int target_index = E.get_edge()->target()->index();
107  OGDF_ASSERT(source_index != target_index); // no self-loop
108  if(source_index < target_index) {
109  return target_index;
110  } else {
111  return source_index;
112  }
113  }
114 };
115 
116 
117 class EdgeMinBucketFunc : public BucketFunc<Edge>
118 {
119 public:
121 
122  int getBucket(const Edge& E) override { return get_min_index(E); }
123 
124 private:
125 
127  int get_min_index(const Edge& E)
128  {
129  int source_index = E.get_edge()->source()->index();
130  int target_index = E.get_edge()->target()->index();
131  OGDF_ASSERT(source_index != target_index); // no self-loop
132  if (source_index < target_index) {
133  return source_index;
134  } else {
135  return target_index;
136  }
137  }
138 };
139 
140 }
141 }
142 }
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:328
int getBucket(const Edge &E) override
Definition: Edge.h:122
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
int getBucket(const Edge &E) override
Definition: Edge.h:100
int index() const
Returns the index of the edge.
Definition: Graph_d.h:324
helping data structure for deleting parallel edges in class FMMMLayout and Multilevel (needed for the...
Definition: Edge.h:42
friend std::ostream & operator<<(std::ostream &output, const Edge &E)
outputstream for Edge
Definition: Edge.h:46
node get_cut_vertex() const
Definition: Edge.h:85
int get_min_index(const Edge &E)
returns the minimum index of e
Definition: Edge.h:127
edge get_edge() const
Definition: Edge.h:83
void set_Edge(edge f, double i, node c)
Definition: Edge.h:76
Class for the representation of edges.
Definition: Graph_d.h:292
Class for the representation of nodes.
Definition: Graph_d.h:169
Abstract base class for bucket functions.
Definition: basic.h:226
Graph * get_Graph_ptr() const
Definition: Edge.h:82
Includes declaration of graph class.
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:203
double get_angle() const
Definition: Edge.h:84
std::istream & operator>>(std::istream &is, TokenIgnorer token)
int get_max_index(const Edge &E)
returns the maximum index of e
Definition: Edge.h:104
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:326
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:71