ROOT
Version master
master
v6.34
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
v6.04
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
gr016_struct.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphs
3
/// \notebook
4
/// Draw a simple graph structure.
5
/// The graph layout is made using graphviz. This macro creates some
6
/// nodes and edges and change a few graphical attributes on some of them.
7
///
8
/// \macro_image
9
/// \macro_code
10
/// \note For this to work, ROOT has to be compiled with gviz ON
11
/// \author Olivier Couet
12
13
TCanvas
*
gr016_struct
()
14
{
15
#if __has_include("TGraphStruct.h")
// handy check on whether gviz was installed
16
TGraphStruct
*
gs
=
new
TGraphStruct
();
17
18
// create some nodes and put them in the graph in one go ...
19
TGraphNode
*
n0
=
gs
->AddNode(
"n0"
,
"Node 0"
);
20
TGraphNode
*
n1
=
gs
->AddNode(
"n1"
,
"First node"
);
21
TGraphNode
*
n2
=
gs
->AddNode(
"n2"
,
"Second node"
);
22
TGraphNode
*
n3
=
gs
->AddNode(
"n3"
,
"Third node"
);
23
TGraphNode
*
n4
=
gs
->AddNode(
"n4"
,
"Fourth node"
);
24
TGraphNode
*
n5
=
gs
->AddNode(
"n5"
,
"5th node"
);
25
TGraphNode
*
n6
=
gs
->AddNode(
"n6"
,
"Node number six"
);
26
TGraphNode
*
n7
=
gs
->AddNode(
"n7"
,
"Node 7"
);
27
TGraphNode
*
n8
=
gs
->AddNode(
"n8"
,
"Node 8"
);
28
TGraphNode
*
n9
=
gs
->AddNode(
"n9"
,
"Node 9"
);
29
30
n4
->SetTextSize(0.03);
31
n6
->SetTextSize(0.03);
32
n2
->SetTextSize(0.04);
33
34
n3
->SetTextFont(132);
35
36
n0
->SetTextColor(
kRed
);
37
38
n9
->SetFillColor(
kRed
-10);
39
n0
->SetFillColor(
kYellow
-9);
40
n7
->SetFillColor(
kViolet
-9);
41
42
// some edges ...
43
gs
->AddEdge(
n0
,
n1
)->SetLineColor(
kRed
);
44
TGraphEdge
*
e06
=
gs
->AddEdge(
n0
,
n6
);
45
e06
->SetLineColor(
kRed
-3);
46
e06
->SetLineWidth(4);
47
gs
->AddEdge(
n1
,
n7
);
48
gs
->AddEdge(
n4
,
n6
);
49
gs
->AddEdge(
n3
,
n9
);
50
gs
->AddEdge(
n6
,
n8
);
51
gs
->AddEdge(
n7
,
n2
);
52
gs
->AddEdge(
n8
,
n3
);
53
gs
->AddEdge(
n2
,
n3
);
54
gs
->AddEdge(
n9
,
n0
);
55
gs
->AddEdge(
n1
,
n4
);
56
gs
->AddEdge(
n1
,
n6
);
57
gs
->AddEdge(
n2
,
n5
);
58
gs
->AddEdge(
n3
,
n6
);
59
gs
->AddEdge(
n4
,
n5
);
60
61
TCanvas
*
c
=
new
TCanvas
(
"c"
,
"c"
,800,600);
62
c
->SetFillColor(38);
63
gs
->Draw();
64
return
c
;
65
#else
66
return
new
TCanvas
(
"c"
,
"c"
,800,600);
67
#endif
68
}
c
#define c(i)
Definition
RSha256.hxx:101
kRed
@ kRed
Definition
Rtypes.h:66
kYellow
@ kYellow
Definition
Rtypes.h:66
kViolet
@ kViolet
Definition
Rtypes.h:67
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TGraphEdge
An edge object connecting two nodes which can be added in a TGraphStruct.
Definition
TGraphEdge.h:25
TGraphNode
A graph node object which can be added in a TGraphStruct.
Definition
TGraphNode.h:27
TGraphStruct
The Graph Structure is an interface to the graphviz package.
Definition
TGraphStruct.h:24
tutorials
visualisation
graphs
gr016_struct.C
ROOT master - Reference Guide Generated on Mon Feb 24 2025 14:45:13 (GVA Time) using Doxygen 1.10.0