
how to add information to an edge?
Quote:
> Hello,
> how can I add some information to an edge of an graph? Exists there an
> attribute, which I can use for a line, which connects two nodes? I use the
> method :
> new(link(in, out, line(arrows := second)))).
> to connect the nodes.
> many thanks,
> Marbod Hopfner
Its not really clear what you want. In general you can add `payload'
information to any object in two ways: subclass the class and add more
instance-variables or attach instance-level attributes to it.
For example:
:- pce_begin_class(mybox, box).
variable(payload, prolog, both, "Associated payload").
:- pce_end_class(mybox).
...,
new(X, mybox),
send(X, payload, hello(world)),
Or:
...,
new(X, box),
send(X, attribute, payload, prolog(hello(world))),
Links and connections are a bit tricky and depend on how you create
the relation. For example:
send(C, attribute, payload, prolog(hello(world))),
after which you can do
payload(Box1, Box2, Payload) :-
get(Box1, connections, Box2, Connections),
get(Connections, size, 1), % ensure there is 1
get(Connections, head, C),
get(C, payload, Payload).
Cheers --- Jan