PandA-2024.02
documentation
tutorial_date_2022
05-context-switch
Exercise4
common
simple_API.h
Go to the documentation of this file.
1
#ifndef __GRAPH_H__
2
#define __GRAPH_H__
3
4
#include <stddef.h>
5
6
#ifndef N_THREADS
7
#define N_THREADS 8
8
#endif
9
10
11
typedef
unsigned
int
NodeId
;
12
typedef
unsigned
int
EdgeId
;
13
typedef
unsigned
int
PropertyId
;
14
15
16
typedef
struct
Edge
{
17
NodeId
node
;
18
PropertyId
property
;
19
}
Edge
;
20
21
#ifndef MAX_VERTEX_NUMBER
22
#define MAX_VERTEX_NUMBER 1309073
23
#endif
24
25
#ifndef MAX_EDGE_NUMBER
26
#define MAX_EDGE_NUMBER 5309056
27
#endif
28
29
typedef
struct
Graph
{
30
size_t
numVertices;
31
// PropertyId * VertexPropertyVector;
32
EdgeId
outEdgesIDs[
MAX_VERTEX_NUMBER
];
33
EdgeId
inEdgesIDs[
MAX_VERTEX_NUMBER
];
34
35
Edge
inEdges[
MAX_EDGE_NUMBER
];
36
Edge
outEdges[
MAX_EDGE_NUMBER
];
37
}
Graph
;
38
39
40
//===----------------------------------------------------------------------===//
41
// Backward Star Interface
42
//===----------------------------------------------------------------------===//
43
44
//size_t getInDegree(Graph * graph, NodeId node);
45
static
inline
size_t
getInDegree
(
Graph
*
graph
,
NodeId
node
) {
46
return
graph->
inEdgesIDs
[node+1] - graph->
inEdgesIDs
[
node
];
47
}
48
49
//Edge * getInEdges(Graph * graph, NodeId node);
50
static
inline
Edge
*
getInEdges
(
Graph
*
graph
,
NodeId
node
) {
51
EdgeId
idx = graph->
inEdgesIDs
[
node
];
52
return
&graph->
inEdges
[idx];
53
}
54
55
//===----------------------------------------------------------------------===//
56
// Forward Star Interface
57
//===----------------------------------------------------------------------===//
58
59
//size_t getOutDegree(Graph * graph, NodeId node);
60
static
inline
size_t
getOutDegree
(
Graph
*
graph
,
NodeId
node
) {
61
return
graph->
outEdgesIDs
[node+1] - graph->
outEdgesIDs
[
node
];
62
}
63
64
//Edge * getOutEdges(Graph * graph, NodeId node);
65
static
inline
Edge
*
getOutEdges
(
Graph
*
graph
,
NodeId
node
) {
66
EdgeId
idx = graph->
outEdgesIDs
[
node
];
67
return
&graph->
outEdges
[idx];
68
}
69
70
extern
void
71
loadGraph
(
char
* InVertexFileName,
char
* OutVertexFileName,
char
* InEdgeFileName,
char
* OutEdgeFileName);
72
73
extern
Graph
TheGraph
;
74
75
extern
unsigned
numAnswers
;
76
77
extern
unsigned
counter
[
N_THREADS
];
78
79
#endif
/* __GRAPH_H__ */
getOutDegree
static size_t getOutDegree(Graph *graph, NodeId node)
Definition:
simple_API.h:60
Graph::inEdgesIDs
EdgeId inEdgesIDs[MAX_VERTEX_NUMBER]
Definition:
simple_API.h:33
Edge::property
PropertyId property
Definition:
simple_API.h:18
PropertyId
unsigned int PropertyId
Definition:
simple_API.h:13
NodeId
unsigned int NodeId
Definition:
simple_API.h:11
numAnswers
unsigned numAnswers
Definition:
data.c:5
Graph::outEdges
Edge outEdges[MAX_EDGE_NUMBER]
Definition:
simple_API.h:36
MAX_EDGE_NUMBER
#define MAX_EDGE_NUMBER
Definition:
simple_API.h:26
Edge::node
NodeId node
Definition:
simple_API.h:17
Graph
struct Graph Graph
Edge
Definition:
simple_API.h:16
getInEdges
static Edge * getInEdges(Graph *graph, NodeId node)
Definition:
simple_API.h:50
Graph::inEdges
Edge inEdges[MAX_EDGE_NUMBER]
Definition:
simple_API.h:35
N_THREADS
#define N_THREADS
Definition:
simple_API.h:7
getOutEdges
static Edge * getOutEdges(Graph *graph, NodeId node)
Definition:
simple_API.h:65
counter
unsigned counter[N_THREADS]
Definition:
data.c:3
TheGraph
Graph TheGraph
Definition:
data.c:7
Edge
struct Edge Edge
getInDegree
static size_t getInDegree(Graph *graph, NodeId node)
Definition:
simple_API.h:45
graph
General class used to describe a graph in PandA.
Definition:
graph.hpp:771
Graph
Definition:
simple_API.h:29
EdgeId
unsigned int EdgeId
Definition:
simple_API.h:12
loadGraph
void loadGraph(char *InVertexFileName, char *OutVertexFileName, char *InEdgeFileName, char *OutEdgeFileName)
Definition:
load_graph.c:10
Graph::outEdgesIDs
EdgeId outEdgesIDs[MAX_VERTEX_NUMBER]
Definition:
simple_API.h:32
MAX_VERTEX_NUMBER
#define MAX_VERTEX_NUMBER
Definition:
simple_API.h:22
Generated on Mon Feb 12 2024 13:02:47 for PandA-2024.02 by
1.8.13