temporarily remove an edge from the graph

41 views
Skip to first unread message

Srirama Bhamidipati

unread,
Apr 29, 2014, 7:31:31 AM4/29/14
to
Hi,

I was wonder what is a good way to remove an edge agent from the graph calculations temporarily ? The removal is based on a threshold value of an attribute of the edge. If the attribute regains it value below a threshold value, i would like that it is reconsidered in the graph calculations. 

I checked "remove", it shows a way to remove items from a list, but I do not know how to add an agent  back to the graph.

regards,
Srirama

Patrick Taillandier

unread,
Apr 29, 2014, 7:25:16 AM4/29/14
to gama-p...@googlegroups.com
Hi,

maybe, the simplest way is to do a copy of your graph:
graph g <- generate_complete_graph(nodeSpecy,edgeSpecy,net_size,false);
graph g_c <- copy(g);
remove edge: one_of (g_c.edges) from: g_c;

cheers,

Patrick


2014-04-29 12:45 GMT+02:00 Srirama Bhamidipati <b.sr...@gmail.com>:
Hi,

I was wonder what is a good way to remove an edge agent from the graph calculations temporarily ? The removal is based on a threshold value of an attribute of the edge. If the attribute regains it attribute value below a threshold value, i would like that it is reconsidered in the graph calculations. 

I checked "remove", it shows a way to remove items from a list, but I do not know how to add an agent  back to the graph.

regards,
Srirama

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

Srirama Bhamidipati

unread,
Apr 29, 2014, 7:39:23 AM4/29/14
to gama-p...@googlegroups.com
Thank you Patrick, but if I remove, how do I add it back ? at the same place, same connections as before. For example, when the edge is taken off, traffic cannot move along it. Later when fixed, traffic can move on it. 

Alexis Drogoul

unread,
Apr 29, 2014, 7:44:35 AM4/29/14
to gama-p...@googlegroups.com
An option in this case could be to leave your graph intact and change the weight of the edge to a very large number.


Le 29 avr. 2014 à 18:39, Srirama Bhamidipati <b.sr...@gmail.com> a écrit :

> Thank you Patrick, but if I remove, how do I add it back ? at the same place, same connections as before. For example, when the edge is taken off, traffic cannot move along it. Later when fixed, traffic can move on it.
>
> --
> You received this message because you are subscribed to the Google Groups "GAMA" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
> To post to this group, send email to gama-p...@googlegroups.com.
> Visit this group at http://groups.google.com/group/gama-platform.
> For more options, visit https://groups.google.com/d/optout.

--
Senior Researcher, UMI UMMISCO 209, IRD & UPMC, France.
Invited Researcher, DREAM, Can Tho University, Viet Nam.
--
alexis....@gmail.com | http://tiny.cc/liqemw
[Vietnam] +84915088155 [France] +33608698845
--
GAMA: https://code.google.com/p/gama-platform/

Patrick Taillandier

unread,
Apr 29, 2014, 7:48:22 AM4/29/14
to gama-p...@googlegroups.com
You can add and remove edges and nodes quite easily in a graph:

add node: a_node to: my_graph;
add edge: node_s::node_t to: my_graph;

remove node: a_node from: my_graph;
remove edge: node_s::node from: my_graph;

There are also some specific operators: add_node and add_edge

Cheers, 

Patrick

PS : the solution of Alexis is good as well



2014-04-29 13:39 GMT+02:00 Srirama Bhamidipati <b.sr...@gmail.com>:
Thank you Patrick, but if I remove, how do I add it back ? at the same place, same connections as before. For example, when the edge is taken off, traffic cannot move along it. Later when fixed, traffic can move on it. 

--

Philippe Caillou

unread,
Apr 29, 2014, 7:59:20 AM4/29/14
to gama-p...@googlegroups.com
Hi,

A related stupid quick question I could'nt answer: how do you change the weight of an edge?

Sorry for the topic-intrusion :)

Philippe

Alexis Drogoul

unread,
Apr 29, 2014, 8:04:32 AM4/29/14
to gama-p...@googlegroups.com
Hi,

I think, but I maybe wrong as I havent touched the graphs for a long time, that something like

g <- g with_weights([edge::w1, edge2::w2]);


should work.

Alexis

Srirama Bhamidipati

unread,
Apr 29, 2014, 8:10:06 AM4/29/14
to
Oki I will try the options. 

Weight can be changed with the as_map operator mapping each edge  to a variable and then using the with_weights as Alexis suggested. I think there is tutorial

Srirama Bhamidipati

unread,
Apr 29, 2014, 8:11:34 AM4/29/14
to gama-p...@googlegroups.com
I think I should use the visible bool for a visual effect while in the background I should increase the weight of an edge. I will try. 
Thanks
Srirama

Patrick Taillandier

unread,
Apr 29, 2014, 8:11:36 AM4/29/14
to gama-p...@googlegroups.com
To change the weight, as Alexis said, you can use the "graph with_weights weights_map" operator.

The as_map operator is usefull when you need to change the weights of all the edges ;) .

g <- g with_weights([edge::w1, edge2::w2]); // change only the weights of edge1 and edge2
g <- g with_weights(road as_map (each::each.shape.perimeter * coeff)); // change the weights of all the road edges.


2014-04-29 14:05 GMT+02:00 Srirama Bhamidipati <b.sr...@gmail.com>:
Oki I will try the options. 

Weight can be changed with the as_map operator mapping each edge  to a variable.

Philippe Caillou

unread,
Apr 29, 2014, 8:16:43 AM4/29/14
to gama-p...@googlegroups.com
thank you!
Reply all
Reply to author
Forward
0 new messages