33 #ifdef OGDF_INCLUDE_CGAL
43 template<
typename Kernel>
44 int count_crossings(std::vector<LineSegment_t<Kernel>>& segments) {
45 unsigned int crossings = 0;
46 for (
unsigned int i = 0; i + 1 < segments.size(); ++i) {
47 for (
unsigned int j = i + 1; j < segments.size(); ++j) {
48 crossings += geometry::do_intersect_open(segments[i], segments[j]);
55 template<
typename Kernel,
typename Graph>
56 int count_crossings(graph::GeometricDrawing<Kernel, Graph>& drawing) {
57 std::vector<LineSegment_t<Kernel>> segments;
59 for (
auto e : drawing.get_graph().edges()) {
60 segments.push_back(drawing.get_segment(e));
62 return count_crossings(segments);
65 template<
typename Kernel,
typename Graph>
66 int count_crossings(graph::GeometricDrawing<Kernel, Graph>& d,
typename Graph::Node& v) {
68 for (
auto f : d.get_graph().edges()) {
69 for (
auto e : d.get_graph().edges(v)) {
70 cr += (f != e) && geometry::do_intersect_open(d.get_segment(e), d.get_segment(f));
76 template<
typename Kernel,
typename Graph>
77 std::vector<int> count_crossings_vec(
const graph::GeometricDrawing<Kernel, Graph>& d,
78 const typename Graph::Node& v) {
79 std::vector<int> cr(v->degree(), 0);
81 for (
auto f : d.get_graph().edges()) {
83 for (
auto e : d.get_graph().edges(v)) {
84 cr[i] += (f != e) && geometry::do_intersect_open(d.get_segment(e), d.get_segment(f));
91 template<
typename Kernel,
typename Graph>
92 int count_crossing_edges(graph::GeometricDrawing<Kernel, Graph>& d,
typename Graph::Node& v) {
94 auto& g = d.get_graph();
96 for (
auto f : g.edges()) {
98 for (
auto e : g.edges(v)) {
99 if ((f != e) && !counted
100 && geometry::do_intersect_open(d.get_segment(e), d.get_segment(f))) {
109 template<
typename Kernel,
typename Graph>
110 int count_crossings(graph::GeometricDrawing<Kernel, Graph>& d,
typename Graph::Edge& e) {
112 for (
auto f : d.get_graph().edges()) {
113 cr += (f != e) && (f->commonNode(e) ==
nullptr)
114 && geometry::do_intersect_open(d.get_segment(e), d.get_segment(f));