Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 {
44  friend std::ostream& operator<<(std::ostream& output, const Edge& E) {
45  output << "edge_index " << E.e->index() << " Graph_ptr " << E.Graph_ptr << " angle"
46  << E.angle << " cut vertex " << E.cut_vertex->index();
47  return output;
48  }
49 
50 #if 0
51  friend std::istream &operator>> (std::istream & input, Edge & E)
53  {
54  input >> E;//.e>>E.Graph_ptr;
55  return input;
56  }
57 #endif
58 
59 public:
61  Edge() {
62  e = nullptr;
63  Graph_ptr = nullptr;
64  angle = 0;
65  cut_vertex = nullptr;
66  }
67 
68  void set_Edge(edge f, Graph* g_ptr) {
69  Graph_ptr = g_ptr;
70  e = f;
71  }
72 
73  void set_Edge(edge f, double i, node c) {
74  angle = i;
75  e = f;
76  cut_vertex = c;
77  }
78 
79  Graph* get_Graph_ptr() const { return Graph_ptr; }
80 
81  edge get_edge() const { return e; }
82 
83  double get_angle() const { return angle; }
84 
85  node get_cut_vertex() const { return cut_vertex; }
86 
87 private:
90  double angle;
92 };
93 
94 class EdgeMaxBucketFunc : public BucketFunc<Edge> {
95 public:
97 
98  int getBucket(const Edge& E) override { return get_max_index(E); }
99 
100 private:
102  int get_max_index(const Edge& E) {
103  int source_index = E.get_edge()->source()->index();
104  int target_index = E.get_edge()->target()->index();
105  OGDF_ASSERT(source_index != target_index); // no self-loop
106  if (source_index < target_index) {
107  return target_index;
108  } else {
109  return source_index;
110  }
111  }
112 };
113 
114 class EdgeMinBucketFunc : public BucketFunc<Edge> {
115 public:
117 
118  int getBucket(const Edge& E) override { return get_min_index(E); }
119 
120 private:
122  int get_min_index(const Edge& E) {
123  int source_index = E.get_edge()->source()->index();
124  int target_index = E.get_edge()->target()->index();
125  OGDF_ASSERT(source_index != target_index); // no self-loop
126  if (source_index < target_index) {
127  return source_index;
128  } else {
129  return target_index;
130  }
131  }
132 };
133 
134 }
135 }
136 }
ogdf::energybased::fmmm::Edge::get_angle
double get_angle() const
Definition: Edge.h:83
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::energybased::fmmm::EdgeMinBucketFunc
Definition: Edge.h:114
ogdf::energybased::fmmm::Edge::get_Graph_ptr
Graph * get_Graph_ptr() const
Definition: Edge.h:79
Graph.h
Includes declaration of graph class.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::energybased::fmmm::EdgeMaxBucketFunc::EdgeMaxBucketFunc
EdgeMaxBucketFunc()
Definition: Edge.h:96
ogdf::NodeElement::index
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:267
ogdf::energybased::fmmm::Edge::angle
double angle
Definition: Edge.h:90
ogdf::energybased::fmmm::EdgeMaxBucketFunc
Definition: Edge.h:94
ogdf::EdgeElement::index
int index() const
Returns the index of the edge.
Definition: Graph_d.h:388
ogdf::energybased::fmmm::Edge::cut_vertex
node cut_vertex
Definition: Edge.h:91
ogdf::energybased::fmmm::Edge
helping data structure for deleting parallel edges in class FMMMLayout and Multilevel (needed for the...
Definition: Edge.h:42
ogdf::BucketFunc
Abstract base class for bucket functions.
Definition: basic.h:255
ogdf::energybased::fmmm::EdgeMinBucketFunc::getBucket
int getBucket(const Edge &E) override
Definition: Edge.h:118
ogdf::energybased::fmmm::EdgeMaxBucketFunc::get_max_index
int get_max_index(const Edge &E)
returns the maximum index of e
Definition: Edge.h:102
ogdf::energybased::fmmm::Edge::operator<<
friend std::ostream & operator<<(std::ostream &output, const Edge &E)
outputstream for Edge
Definition: Edge.h:44
ogdf::energybased::fmmm::EdgeMinBucketFunc::EdgeMinBucketFunc
EdgeMinBucketFunc()
Definition: Edge.h:116
ogdf::energybased::fmmm::Edge::Graph_ptr
Graph * Graph_ptr
Definition: Edge.h:89
ogdf::energybased::fmmm::Edge::set_Edge
void set_Edge(edge f, Graph *g_ptr)
Definition: Edge.h:68
ogdf::energybased::fmmm::EdgeMaxBucketFunc::getBucket
int getBucket(const Edge &E) override
Definition: Edge.h:98
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:391
ogdf::energybased::fmmm::EdgeMinBucketFunc::get_min_index
int get_min_index(const Edge &E)
returns the minimum index of e
Definition: Edge.h:122
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::energybased::fmmm::Edge::set_Edge
void set_Edge(edge f, double i, node c)
Definition: Edge.h:73
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::energybased::fmmm::Edge::get_edge
edge get_edge() const
Definition: Edge.h:81
ogdf::energybased::fmmm::Edge::e
edge e
Definition: Edge.h:88
ogdf::operator>>
std::istream & operator>>(std::istream &is, TokenIgnorer token)
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::energybased::fmmm::Edge::Edge
Edge()
constructor
Definition: Edge.h:61
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::energybased::fmmm::Edge::get_cut_vertex
node get_cut_vertex() const
Definition: Edge.h:85