33 #ifdef OGDF_INCLUDE_CGAL
54 class OGDFGraphWrapper {
61 std::shared_ptr<Graph> self_generated_graph;
64 static void id_sg_handle_node(Node, Node) { }
66 static void id_sg_handle_edge(Edge, Edge) { }
70 OGDFGraphWrapper() : self_generated_graph(new
Graph()), graph(*self_generated_graph) {
74 OGDFGraphWrapper(
const Graph& _graph) : self_generated_graph(nullptr), graph(_graph) {
78 ~OGDFGraphWrapper() { }
80 inline const Graph& get_graph() {
return graph; }
82 inline const Graph& get_ogdf_graph() {
return graph; }
84 inline size_t number_of_nodes()
const {
return graph.numberOfNodes(); }
86 inline size_t number_of_edges()
const {
return graph.numberOfEdges(); }
88 inline size_t max_node_index()
const {
return graph.maxNodeIndex(); }
90 inline size_t max_edge_index()
const {
return graph.maxEdgeIndex(); }
92 inline Node get_node(
unsigned int i)
const {
93 for (
auto w : nodes()) {
94 if (w->index() == (
int)i) {
107 inline Edge search_edge(Node v, Node w)
const {
108 if (v->degree() < w->degree()) {
109 for (
auto e : edges(v)) {
110 if (e->opposite(v) == w) {
116 for (
auto e : edges(w)) {
117 if (e->opposite(w) == v) {
130 inline bool are_adjacent(Node v, Node w)
const {
return search_edge(v, w) !=
nullptr; }
135 inline datastructure::IteratorRange<NodeIterator> nodes()
const {
136 if (number_of_nodes() > 0) {
137 return datastructure::IteratorRange<NodeIterator>(
NodeIterator(graph.firstNode()),
140 return datastructure::IteratorRange<NodeIterator>(
Node(0),
Node(0));
147 inline datastructure::IteratorRange<EdgeIterator> edges()
const {
148 if (number_of_edges() > 0) {
149 return datastructure::IteratorRange<EdgeIterator>(
EdgeIterator(graph.firstEdge()),
152 return datastructure::IteratorRange<EdgeIterator>(
Edge(0),
Edge(0));
160 inline datastructure::IteratorRange<IncidentEdgeIterator> edges(
const Node w)
const {
161 if (w->degree() == 0) {
162 return datastructure::IteratorRange<IncidentEdgeIterator>(
165 return datastructure::IteratorRange<IncidentEdgeIterator>(
166 IncidentEdgeIterator(w->firstAdj()), IncidentEdgeIterator(w->lastAdj()->succ()));
175 inline datastructure::IteratorRange<AdjEntryIterator> adj(
const Node w)
const {
176 if (w->degree() == 0) {
180 return datastructure::IteratorRange<AdjEntryIterator>(
AdjEntryIterator(w->firstAdj()),
189 inline datastructure::IteratorRange<AdjacentNodeIterator> neighbors(
const Node w)
const {
190 if (w->degree() == 0) {
191 return datastructure::IteratorRange<AdjacentNodeIterator>(
195 return datastructure::IteratorRange<AdjacentNodeIterator>(
196 AdjacentNodeIterator(w->firstAdj()), AdjacentNodeIterator(w->lastAdj()->succ()));