DPsim
Loading...
Searching...
No Matches
dpsim-models
include
dpsim-models
Graph.h
1
/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2
* EONERC, RWTH Aachen University
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
*********************************************************************************/
8
9
#pragma once
10
11
#include <map>
12
13
#include <graphviz/cgraph.h>
14
15
#include <dpsim-models/Definitions.h>
16
17
namespace
CPS {
18
namespace
Graph {
19
20
enum class
Type { undirected, directed };
21
22
class
Graph
;
23
24
class
Element
{
25
26
protected
:
27
void
*mPtr;
28
int
mKind;
29
30
public
:
31
void
set(
const
String &key,
const
String &value,
bool
html =
false
);
32
};
33
34
class
Node :
public
Element
{
35
public
:
36
Agnode_t *mNode;
37
38
Node(
Graph
*g,
const
String &name);
39
};
40
41
class
Edge :
public
Element
{
42
public
:
43
Agedge_t *mEdge;
44
45
Edge(
Graph
*g,
const
String &name,
Node
*head,
Node
*tail);
46
};
47
48
// See: http://www.graphviz.org/pdf/libguide.pdf
49
class
Graph :
public
Element
{
50
51
protected
:
52
std::map<String, Node *> mNodes;
53
std::map<String, Edge *> mEdges;
54
55
public
:
56
Agraph_t *mGraph;
57
58
Graph(
const
String &name, Type type,
bool
strict =
false
);
59
~Graph();
60
61
void
render(std::ostream &os,
const
String &layout =
"dot"
,
62
const
String &format =
"svg"
);
63
64
Node
*addNode(
const
String &name);
65
Edge
*addEdge(
const
String &name,
Node
*head,
Node
*tail);
66
67
Node
*node(
const
String &name);
68
Edge
*edge(
const
String &name);
69
};
70
}
// namespace Graph
71
}
// namespace CPS
CPS::Graph::Edge
Definition
Graph.h:41
CPS::Graph::Element
Definition
Graph.h:24
CPS::Graph::Graph
Definition
Graph.h:49
CPS::Graph::Node
Definition
Graph.h:34
Generated by
1.13.2