Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
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
39namespace ogdf {
40namespace energybased {
41namespace fmmm {
42
45class 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
55 friend std::istream &operator>> (std::istream & input, Edge & E)
56 {
57 input >> E;//.e>>E.Graph_ptr;
58 return input;
59 }
60#endif
61
62public:
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
90private:
93 double angle;
95};
96
97class EdgeMaxBucketFunc : public BucketFunc<Edge> {
98public:
100
101 int getBucket(const Edge& E) override { return get_max_index(E); }
102
103private:
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
117class EdgeMinBucketFunc : public BucketFunc<Edge> {
118public:
120
121 int getBucket(const Edge& E) override { return get_min_index(E); }
122
123private:
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}
Includes declaration of graph class.
Basic declarations, included by all source files.
Abstract base class for bucket functions.
Definition basic.h:257
Class for the representation of edges.
Definition Graph_d.h:364
int index() const
Returns the index of the edge.
Definition Graph_d.h:396
node target() const
Returns the target node of the edge.
Definition Graph_d.h:402
node source() const
Returns the source node of the edge.
Definition Graph_d.h:399
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Class for the representation of nodes.
Definition Graph_d.h:241
int index() const
Returns the (unique) node index.
Definition Graph_d.h:275
helping data structure for deleting parallel edges in class FMMMLayout and Multilevel (needed for the...
Definition Edge.h:45
void set_Edge(edge f, Graph *g_ptr)
Definition Edge.h:71
friend std::ostream & operator<<(std::ostream &output, const Edge &E)
outputstream for Edge
Definition Edge.h:47
node get_cut_vertex() const
Definition Edge.h:88
void set_Edge(edge f, double i, node c)
Definition Edge.h:76
edge get_edge() const
Definition Edge.h:84
Graph * get_Graph_ptr() const
Definition Edge.h:82
double get_angle() const
Definition Edge.h:86
int getBucket(const Edge &E) override
Definition Edge.h:101
int get_max_index(const Edge &E)
returns the maximum index of e
Definition Edge.h:105
int get_min_index(const Edge &E)
returns the minimum index of e
Definition Edge.h:125
int getBucket(const Edge &E) override
Definition Edge.h:121
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.
std::istream & operator>>(std::istream &is, TokenIgnorer token)