|
|
| Author |
Message |
< Erlang ~ Getting edge from vetice to vetice in digraph |
| saketkunwar |
Posted: Fri Feb 13, 2009 6:59 am |
|
|
|
Joined: 11 Feb 2009
Posts: 6
|
Hi
There is no direct function to get the edge from vertice to vertice in digraph i.e something like Edge=digraph:vertice(V1,V2) so i cooked this crude stuff.I am using digraph as undirectional graph by providing both out and in edges to each vertices.The code below extracts all the outgoing edges from one vertice and all the ingoing edges from the other vertice then compare both list of edges.the common edges should be the one that connects the two vertices.
Is there a more direct and efficent procedure to get the vertices??.
edgeVtoV(G,Vertice_from,Vertice_to)->
E1=digraph:out_edges(G,Vertice_from),
E2=digraph:in_edges(G,Vertice_to),
Edge=comp(E1,E2).
comp([Eh|Et],E2)->
Bool=lists:member(Eh,E2),
if
(Bool==true)->
comp([],Eh);
(Bool==false)->
comp(Et,E2)
end;
comp([],Edge)->
Edge.
saket |
|
|
| Back to top |
|
| keymone |
Posted: Fri Feb 13, 2009 8:26 am |
|
|
|
User
Joined: 17 Sep 2007
Posts: 11
Location: Lviv, Ukraine
|
more efficient way would be to store binary where bit i*n+j is set to 1 if edge between V_i and V_j exists(bit j*n+i would be 1 as well because your graph is undirected)
tradeoff is that you have to update binary every time you add/remove edges/vertices.
P.S. n is number of vertices |
|
|
| Back to top |
|
| wyborowiec |
Posted: Fri Feb 20, 2009 1:43 pm |
|
|
|
Joined: 01 Dec 2008
Posts: 4
Location: Poland
|
You can also get final edge through lists comprehension:
Res = [ Edge1 || Edge1 <- E1, Edge2 <- E2, Edge1 == Edge2]
It's surely a shorter solution, but I wonder what about the performance...
In case of a big graph, e.g. 10000x10000 nodes, using keymone's solution we get additional structure of about 12MB. |
|
|
| Back to top |
|
| wuji |
Posted: Mon Aug 27, 2012 6:49 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
manager of the Golden Lamb, the historic restaurant and inn inn cheap authentic jordans inn in Lebanon, Ohio, which has been owned by Portman's
since 1926 — and where Portman usually orders the duck duck cheap designer *beep* duck breast and the lingonberry jus. "I think he would
tremendous at whatever he does."People in Ohio who have grown grown [h2]cheap Ralph Lauren[/h2] grown to know Portman well say that even if he
to become vice president, he wouldn't abandon his roots in in [h2]cheap Ralph Lauren[/h2] in the swing state from which he hails.Portman has forged
relationship with the parents of Matt Maupin, an Army sergeant sergeant cheap polo shirts sergeant from Ohio who was captured in Iraq in 2004,
later killed by insurgents. While Maupin was missing, Portman set set real jordans set up a meeting between President Bush and Maupin's parents,
a |
|
|
| Back to top |
|
| dongdongwu |
Posted: Thu Sep 20, 2012 2:11 am |
|
|
|
User
Joined: 19 Sep 2012
Posts: 236
|
His good friend Diane said: "Christian Louboutin Men Shoes was a magician, he make shoes is immediately put his female people with legs and advantage. He understands women wanted to do and can make them into beautiful Cinderella." Madonna often in its concert wearing Christian louboutin high heels , and some famous superstar like Angelina jolie, mariah Carey, beyonce Knowles, the famous Japanese singer YaYouMei Hamasaki helps Christian Louboutin Men Shoes set up its powerful position. The youngest customers will count Tom cruise's daughter sully cruz. Louboutin made for only a pair of handmade Christian Louboutin high heel Shoes! Want to be more fashion? Put on Christian Louboutin Outlet !
Candy colors of the chalaza high-heeled shoes with lolita type allure, set full finely gem blue "neon shoes" is to need to use "sexy" to describe. Each pair are worth careful appreciation of lithe and graceful fairy ludaoli, what kind of most let you move?Christian Louboutin Men Shoes that one brush red is always cannot resist the temptation, Christian Louboutin men outlet continue to use the days of high 8cm above slender heel proclaim the sexy and luxuriant. The bowknot on black pointed high-heeled shoes with sharp rivet concomitant, wild python met enchanting color printing grain, It is that pairs of high-heeled shoes lets Carrie more feminine flavour. Like Christian Louboutin for men her word. |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|