Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
EdgeWeightedGraphCopy.h
Go to the documentation of this file.
1
32#pragma once
33
36
37namespace ogdf {
38
39template<typename T>
41public:
43
47
49
50 void createEmpty(const Graph& wG);
51 void init(const EdgeWeightedGraph<T>& wG);
52 edge newEdge(node u, node v, T weight);
54
55 T weight(const edge e) const { return m_edgeWeight[e]; }
56
57 void setWeight(const edge e, T v) { m_edgeWeight[e] = v; }
58
59 const EdgeArray<T>& edgeWeights() const { return m_edgeWeight; }
60
61protected:
63
64private:
66};
67
68}
69
70// Implementation
71
72namespace ogdf {
73
74template<typename T>
77 m_pGraph = wGC.m_pGraph;
78
79 m_vOrig.init(*this, 0);
80 m_eOrig.init(*this, 0);
81 m_vCopy.init(*m_pGraph, 0);
82 m_eCopy.init(*m_pGraph);
83 m_eIterator.init(*this, 0);
84
85 for (node v : wGC.nodes) {
86 m_vOrig[vCopy[v]] = wGC.original(v);
87 }
88
89 for (edge e : wGC.edges) {
90 m_eOrig[eCopy[e]] = wGC.original(e);
91 }
92
93 for (node v : nodes) {
94 node w = m_vOrig[v];
95 if (w != nullptr) {
96 m_vCopy[w] = v;
97 }
98 }
99
100 for (edge e : m_pGraph->edges) {
102 for (it = wGC.m_eCopy[e].begin(); it.valid(); ++it) {
103 m_eIterator[eCopy[*it]] = m_eCopy[e].pushBack(eCopy[*it]);
104 }
105 }
106
107 m_edgeWeight.init(*this);
108
109 for (edge e : wGC.edges) {
110 m_edgeWeight[eCopy[e]] = wGC.weight(e);
111 }
112}
113
114template<typename T>
117
118 m_edgeWeight.init(*this);
119
120 for (edge e : wGC.edges) {
121 const edge f = wGC.original(e);
122 m_edgeWeight[copy(f)] = wGC.weight(e);
123 }
124
125 return *this;
126}
127
128template<typename T>
130 : GraphCopy(wGC), m_edgeWeight(*this) {
131 for (edge e : wGC.edges) {
132 const edge f = wGC.original(e);
133 m_edgeWeight[copy(f)] = wGC.weight(e);
134 }
135}
136
137template<typename T>
139 : GraphCopy(wG), m_edgeWeight(*this) {
140 for (edge e : edges) {
141 m_edgeWeight[e] = wG.weight(original(e));
142 }
143}
144
145template<typename T>
148
149 m_edgeWeight.init(*this);
150 for (edge e : edges) {
151 m_edgeWeight[e] = wG.weight(original(e));
152 }
153}
154
155template<typename T>
158 m_pGraph = &G;
159 m_edgeWeight.init(*this);
160}
161
162template<typename T>
164 edge e = GraphCopy::newEdge(u, v);
165 m_edgeWeight[e] = weight;
166 return e;
167}
168
169template<typename T>
172 m_edgeWeight[e] = weight;
173 return e;
174}
175
176}
Declaration of class EdgeWeightedGraph.
Declaration of graph copy classes.
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
edge newEdge(node u, node v, T weight)
const EdgeArray< T > & edgeWeights() const
void initWGC(const EdgeWeightedGraphCopy &wGC, NodeArray< node > &vCopy, EdgeArray< edge > &eCopy)
void init(const EdgeWeightedGraph< T > &wG)
void setWeight(const edge e, T v)
EdgeWeightedGraphCopy & operator=(const EdgeWeightedGraphCopy &wGC)
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:254
GraphCopy & operator=(const GraphCopy &GC)
Assignment operator.
void init(const Graph &G)
Re-initializes the copy using the graph G.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
Definition GraphCopy.h:338
const Graph & original() const
Returns a reference to the original graph.
Definition GraphCopy.h:289
void createEmpty(const Graph &G)
Associates the graph copy with G, but does not create any nodes or edges.
edge newEdge(edge eOrig)
Creates a new edge (v,w) with original edge eOrig.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition Graph_d.h:592
Encapsulates a pointer to a list element.
Definition List.h:103
bool valid() const
Returns true iff the iterator points to an element.
Definition List.h:137
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.