Graph
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef INCLUDED_C_EDGE_H
|
||||
#define INCLUDED_C_EDGE_H
|
||||
|
||||
#ifndef INCLUDED_C_TYPES_H
|
||||
#include <c_Types.h>
|
||||
#endif /*INCLUDED_C_TYPES_H*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
typedef struct {
|
||||
c_size_t v; /* One endpoint vertex */
|
||||
c_size_t w; /* The other endpoint vertex */
|
||||
double weight; /* Edge weight value */
|
||||
} c_Edge_t;
|
||||
|
||||
#define C_EDGE_SENTINEL ((c_size_t)-1)
|
||||
|
||||
/* Inline helper methods for c_Edge_t */
|
||||
C_STATIC_FORCE_INLINE
|
||||
c_size_t c_Edge_Either(const c_Edge_t* edge) {
|
||||
return edge ? edge->v : 0;
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE
|
||||
c_size_t c_Edge_Other(const c_Edge_t* edge, c_size_t v) {
|
||||
if (!edge) return 0;
|
||||
return (edge->v == v) ? edge->w : edge->v;
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE double c_Edge_Weight(const c_Edge_t* edge) {
|
||||
return edge ? edge->weight : 0.0;
|
||||
}
|
||||
|
||||
#endif /*INCLUDED_C_EDGE_H*/
|
||||
Reference in New Issue
Block a user