This allows the edge_info callback to supply a cost or length for an edge.
For now we only support 'long' valued costs. If the callback doesn't
supply a cost, it's considered cost 1.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
rc = g->edge_info(g, n, e, ei);
assert(rc <= 0);
return rc;
rc = g->edge_info(g, n, e, ei);
assert(rc <= 0);
return rc;
* reference to that node by the edge callback for *any* node and
* index MUST use the same pointer.
*
* reference to that node by the edge callback for *any* node and
* index MUST use the same pointer.
*
+ * - The ei->icost field MAY be set by the edge_info callback to
+ * indicate the edge's cost / length represented as an integer (of
+ * type aga_icost_t), Otherwise the cost defaults to 1.
+ *
* Concurrency
* ===========
*
* Concurrency
* ===========
*
const struct aga_node *n,
const void *e);
const struct aga_node *n,
const void *e);
+typedef long aga_icost_t;
+
struct aga_edge_info {
struct aga_node *to;
struct aga_edge_info {
struct aga_node *to;
+ aga_icost_t icost; /* integer edge cost */
typedef int (*aga_edge_info_fn)(const struct aga_graph *g,
const struct aga_node *n,
const void *e, struct aga_edge_info *ei);
typedef int (*aga_edge_info_fn)(const struct aga_graph *g,
const struct aga_node *n,
const void *e, struct aga_edge_info *ei);
+ eir.icost = ei->icost; /* Inherit the default from aga */
rc = sr->gr->edge_info(sr->gr, nr, e, &eir);
rc = sr->gr->edge_info(sr->gr, nr, e, &eir);
+ ei->icost = eir.icost;
+
rc = gr->edge_info(gr, nr, e, eir);
assert(rc <= 0);
return rc;
rc = gr->edge_info(gr, nr, e, eir);
assert(rc <= 0);
return rc;
struct agar_edge_info {
const void *to;
struct agar_edge_info {
const void *to;
+ aga_icost_t icost; /* integer edge cost */