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 #include <ogdf/basic/basic.h>
36 
37 #include <ostream>
38 
39 namespace ogdf {
40 namespace energybased {
41 namespace fmmm {
42 
45 class Edge {
47  friend std::ostream& operator<<(std::ostream& output, const Edge& E) {
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 
84  edge get_edge() const { return e; }
85 
86  double get_angle() const { return angle; }
87 
88  node get_cut_vertex() const { return cut_vertex; }
89 
90 private:
93  double angle;
95 };
96 
97 class EdgeMaxBucketFunc : public BucketFunc<Edge> {
98 public:
100 
101  int getBucket(const Edge& E) override { return get_max_index(E); }
102 
103 private:
105  int get_max_index(const Edge& E) {
106  int source_index = E.get_edge()->source()->index();
107  int target_index = E.get_edge()->target()->index();
108  OGDF_ASSERT(source_index != target_index); // no self-loop
109  if (source_index < target_index) {
110  return target_index;
111  } else {
112  return source_index;
113  }
114  }
115 };
116 
117 class EdgeMinBucketFunc : public BucketFunc<Edge> {
118 public:
120 
121  int getBucket(const Edge& E) override { return get_min_index(E); }
122 
123 private:
125  int get_min_index(const Edge& E) {
126  int source_index = E.get_edge()->source()->index();
127  int target_index = E.get_edge()->target()->index();
128  OGDF_ASSERT(source_index != target_index); // no self-loop
129  if (source_index < target_index) {
130  return source_index;
131  } else {
132  return target_index;
133  }
134  }
135 };
136 
137 }
138 }
139 }
ogdf::energybased::fmmm::Edge::get_angle
double get_angle() const
Definition: Edge.h:86
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::energybased::fmmm::EdgeMinBucketFunc
Definition: Edge.h:117
ogdf::energybased::fmmm::Edge::get_Graph_ptr
Graph * get_Graph_ptr() const
Definition: Edge.h:82
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:66
ogdf::energybased::fmmm::EdgeMaxBucketFunc::EdgeMaxBucketFunc
EdgeMaxBucketFunc()
Definition: Edge.h:99
ogdf::NodeElement::index
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:274
ogdf::energybased::fmmm::Edge::angle
double angle
Definition: Edge.h:93
ogdf::energybased::fmmm::EdgeMaxBucketFunc
Definition: Edge.h:97
ogdf::EdgeElement::index
int index() const
Returns the index of the edge.
Definition: Graph_d.h:395
ogdf::energybased::fmmm::Edge::cut_vertex
node cut_vertex
Definition: Edge.h:94
ogdf::energybased::fmmm::Edge
helping data structure for deleting parallel edges in class FMMMLayout and Multilevel (needed for the...
Definition: Edge.h:45
ogdf::BucketFunc
Abstract base class for bucket functions.
Definition: basic.h:257
ogdf::energybased::fmmm::EdgeMinBucketFunc::getBucket
int getBucket(const Edge &E) override
Definition: Edge.h:121
ogdf::energybased::fmmm::EdgeMaxBucketFunc::get_max_index
int get_max_index(const Edge &E)
returns the maximum index of e
Definition: Edge.h:105
ogdf::energybased::fmmm::Edge::operator<<
friend std::ostream & operator<<(std::ostream &output, const Edge &E)
outputstream for Edge
Definition: Edge.h:47
ogdf::energybased::fmmm::EdgeMinBucketFunc::EdgeMinBucketFunc
EdgeMinBucketFunc()
Definition: Edge.h:119
ogdf::energybased::fmmm::Edge::Graph_ptr
Graph * Graph_ptr
Definition: Edge.h:92
ogdf::energybased::fmmm::Edge::set_Edge
void set_Edge(edge f, Graph *g_ptr)
Definition: Edge.h:71
ogdf::energybased::fmmm::EdgeMaxBucketFunc::getBucket
int getBucket(const Edge &E) override
Definition: Edge.h:101
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:398
ogdf::energybased::fmmm::EdgeMinBucketFunc::get_min_index
int get_min_index(const Edge &E)
returns the minimum index of e
Definition: Edge.h:125
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::energybased::fmmm::Edge::set_Edge
void set_Edge(edge f, double i, node c)
Definition: Edge.h:76
basic.h
Basic declarations, included by all source files.
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::energybased::fmmm::Edge::get_edge
edge get_edge() const
Definition: Edge.h:84
ogdf::energybased::fmmm::Edge::e
edge e
Definition: Edge.h:91
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:401
ogdf::energybased::fmmm::Edge::Edge
Edge()
constructor
Definition: Edge.h:64
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::energybased::fmmm::Edge::get_cut_vertex
node get_cut_vertex() const
Definition: Edge.h:88