Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
bellman_ford.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file bellman_ford.h
1
/* This software is distributed under the GNU Lesser General Public License */
2
//==========================================================================
3
//
4
// bellman_ford.h
5
//
6
//==========================================================================
7
// $Id: bellman_ford.h,v 1.5 2003/03/24 15:58:54 raitner Exp $
8
9
#ifndef GTL_BELLMAN_FORD_H
10
#define GTL_BELLMAN_FORD_H
11
12
#include <
GTL/GTL.h
>
13
#include <
GTL/algorithm.h
>
14
#include <
GTL/node_map.h
>
15
#include <
GTL/edge_map.h
>
16
17
__GTL_BEGIN_NAMESPACE
18
19
33
class
GTL_EXTERN
bellman_ford
:
public
algorithm
34
{
35
public
:
36
40
bellman_ford
();
41
45
virtual
~
bellman_ford
();
46
58
int
check
(
graph
&
G
);
59
60
int
run
(
graph
& G);
61
68
void
reset
();
69
79
void
source
(
const
node
&
n
) {
s
=
n
;}
80
86
node
source
()
const
{
return
s
;}
87
95
void
weights
(
const
edge_map<double>
& weight) {w = weight; vars_set =
true
; }
96
107
void
store_preds (
bool
set
);
108
117
bool
store_preds
()
const
{
return
preds != 0;}
118
124
bool
reached
(
const
node
&
n
)
const
{
return
!
inf
[
n
];}
125
131
double
distance
(
const
node
&
n
)
const
{
return
d[
n
];}
132
147
edge
predecessor_edge (
const
node
&
n
)
const
148
{
assert
(preds);
return
(*preds)[
n
];}
149
164
node
predecessor_node (
const
node
&
n
)
const
165
{
edge
e
= predecessor_edge(n);
return
e ==
edge
() ?
node
() : e.
opposite
(n); }
166
171
bool
negative_cycle()
const
172
{
return
cycle;}
173
174
private
:
175
176
182
void
relax (
const
edge
&
e
,
bool
dir);
183
189
node
s
;
190
196
edge_map<double>
w
;
197
203
bool
vars_set
;
204
210
node_map<double>
d
;
211
217
node_map<bool>
inf
;
218
224
node_map<edge>
*
preds
;
225
232
bool
cycle
;
233
};
234
235
__GTL_END_NAMESPACE
236
237
#endif // GTL_BELLMAN_FORD_H
JETSCAPE
blob
main
external_packages
gtl
include
GTL
bellman_ford.h
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:23
using
1.8.2 with
sPHENIX GitHub integration