Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Convert sumolib.net.readnet Graph to Adjacency Matrix

Thanks for reply harald sir.

Is there any way to convert all the edges to bidirectional? Or any other solution,if you may suggest?

I have modify the code as following :
def get_EdgeId_From_vertex(prenode,nextnode):
    # Retrive Edge Id from Graph by giving Previous Node and Next Node
    for x in graph.getNodes():
        if(str(int(x.getID()) - 1) == str(prenode)):
            #print 'Out Going Edge of :' + str(x.getID()) + ' Are ' + str(x.getOutgoing())
            for edge in x.getOutgoing():
                #check if Next node of this edge is nextnode??
                if(int(str(edge.getToNode().getID()))-1 == nextnode):
                    return str(edge.getID())

            for edge in x.getIncoming():
                #check if Next node of this edge is nextnode??
                if(int(str(edge.getFromNode().getID()))-1 == nextnode):
                    return str(edge.getID())

But this gives error :
traci.exceptions.TraCIException: Vehicle 'vehicle0' has no valid route. No connection between edge '8' and edge '11'.



On Wed, Apr 3, 2019 at 5:04 PM <sumo-user-request@xxxxxxxxxxx> wrote:
Send sumo-user mailing list submissions to
        sumo-user@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
        https://www.eclipse.org/mailman/listinfo/sumo-user
or, via email, send a message with subject or body 'help' to
        sumo-user-request@xxxxxxxxxxx

You can reach the person managing the list at
        sumo-user-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of sumo-user digest..."


Today's Topics:

   1. Re: Convert sumolib.net.readnet Graph to Adjacency Matrix
      (Bijal) (Harald Schaefer)


----------------------------------------------------------------------

Message: 1
Date: Wed, 3 Apr 2019 11:04:38 +0200
From: Harald Schaefer <fechsaer@xxxxxxxxx>
To: sumo-user@xxxxxxxxxxx
Subject: Re: [sumo-user] Convert sumolib.net.readnet Graph to
        Adjacency Matrix (Bijal)
Message-ID: <71dfa043-d2d0-0f73-5771-f640d4d01666@xxxxxxxxx>
Content-Type: text/plain; charset="utf-8"

Hi Bijal,

when constructing your internal graph you must look at the direction of
edges (and preserve them).
In the original net the node 10 (or 9 in your notation) has only
incoming edges, so it cannot be an intermediate node on a valid route.

Greetings, Harald

Am 03.04.19 um 07:42 schrieb Bijal:
> Dear?Michael,
> AS per your suggestion,I have written code to get Edge Id from
> supplied Previous node and NextNode.
>
> But in the case where? previous??edge (Say 5) and next edge (Say 3), I
> am not getting Edge Id. Because i am using?*for edge in x.getOutgoing().*
> *
> *
> *Is there any way to get all the edges attached with node say X?*
>
> for x in graph.getNodes():
> ? ? ? ? if(str(int(x.getID()) - 1) == str(prenode)):
> ? ? ? ? ? ? print 'Out Going Edge of :' + str(x.getID()) + ' Are ' +
> str(x.getOutgoing())
> *? ? ? ? ? ? for edge in x.getOutgoing():*
> ? ? ? ? ? ? ? ? #print str(int(str(edge.getToNode().getID()))-1) + '
> == ' + str(nextnode)
> ? ? ? ? ? ? ? ? #check if Next node of this edge is nextnode??
> ? ? ? ? ? ? ? ? if(int(str(edge.getToNode().getID()))-1 == nextnode):
> ? ? ? ? ? ? ? ? ? ? print 'Selected Edge ID is ' + str(edge.getID())
> ? ? ? ? ? ? ? ? ? ? return str(edge.getID())
> Output :
>
> *trace [0, 6, 9, 7, 8, 3, 2, 1, 5, 4] ----> List of nodes to be
> selected in the route*
> *
> *
> Out Going Edge of :1 Are [<edge id="1" from="1" to="2"/>, <edge id="2"
> from="1" to="7"/>]
> Selected Edge ID is 2
>
> Out Going Edge of :7 Are [<edge id="14" from="7" to="8"/>, <edge
> id="15" from="7" to="10"/>]
> Selected Edge ID is 15
>
> Out Going Edge of :10 Are []
> *--No Edge identified*
> Out Going Edge of :8 Are [<edge id="16" from="8" to="9"/>, <edge
> id="17" from="8" to="10"/>]
> *Selected Edge ID is 16*
>
> Out Going Edge of :9 Are [<edge id="18" from="9" to="10"/>]
> *--No Edge identified*??
>
> Out Going Edge of :4 Are [<edge id="7" from="4" to="5"/>, <edge id="8"
> from="4" to="9"/>]
> *--No Edge identified*??
>
> Out Going Edge of :3 Are [<edge id="5" from="3" to="5"/>, <edge id="6"
> from="3" to="4"/>]
> *--No Edge identified*??
>
> Out Going Edge of :2 Are [<edge id="3" from="2" to="3"/>, <edge id="4"
> from="2" to="6"/>]
> Selected Edge ID is 4
>
> Out Going Edge of :6 Are [<edge id="12" from="6" to="7"/>, <edge
> id="13" from="6" to="8"/>]
> *--No Edge identified*
>
>
> On Fri, Mar 29, 2019 at 8:29 PM Bijal <bijal.varia88@xxxxxxxxx
> <mailto:bijal.varia88@xxxxxxxxx>> wrote:
>
>     Dear Sir,
>
>     Now adjacency matrix filled fine and ACO ALGORITHM works nicely.
>
>     I am getting list of vertexes, Traversed by ant in shortest way :?
>
>     Like [0,1,3,4,5,7,8,9,6,2]
>
>     Issue : I can get from and to field to build edge using this vertex.
>
>     But to create a route I need following :
>     <Edge Id= from= to=>
>
>     Is there anyway to get edge ID to build a route out of this vertex
>     list?
>
>
>
>     On Wed 27 Mar, 2019, 5:22 PM , <sumo-user-request@xxxxxxxxxxx
>     <mailto:sumo-user-request@xxxxxxxxxxx>> wrote:
>
>         Send sumo-user mailing list submissions to
>         ? ? ? ? sumo-user@xxxxxxxxxxx <mailto:sumo-user@xxxxxxxxxxx>
>
>         To subscribe or unsubscribe via the World Wide Web, visit
>         ? ? ? ? https://www.eclipse.org/mailman/listinfo/sumo-user
>         or, via email, send a message with subject or body 'help' to
>         ? ? ? ? sumo-user-request@xxxxxxxxxxx
>         <mailto:sumo-user-request@xxxxxxxxxxx>
>
>         You can reach the person managing the list at
>         ? ? ? ? sumo-user-owner@xxxxxxxxxxx
>         <mailto:sumo-user-owner@xxxxxxxxxxx>
>
>         When replying, please edit your Subject line so it is more
>         specific
>         than "Re: Contents of sumo-user digest..."
>
>
>         Today's Topics:
>
>         ? ?1. Re: Traffic Light (iCashWave)
>         ? ?2. Re: Traffic Light (Jakob Erdmann)
>         ? ?3. Re: Convert sumolib.net.readnet Graph to Adjacency? ? ?
>         ? Matrix (Bijal)
>
>
>         ----------------------------------------------------------------------
>
>         Message: 1
>         Date: Wed, 27 Mar 2019 18:24:50 +0800
>         From: iCashWave <icashwave@xxxxxxxxx <mailto:icashwave@xxxxxxxxx>>
>         To: Sumo project User discussions <sumo-user@xxxxxxxxxxx
>         <mailto:sumo-user@xxxxxxxxxxx>>
>         Subject: Re: [sumo-user] Traffic Light
>         Message-ID:
>         ? ? ? ?
>         <CAAUjJ+U+XCxi9Uy_BuKw+wG9c_Q2w5xOy-rjF7Gg+pUCJf1H2g@xxxxxxxxxxxxxx
>         <mailto:CAAUjJ%2BU%2BXCxi9Uy_BuKw%2BwG9c_Q2w5xOy-rjF7Gg%2BpUCJf1H2g@xxxxxxxxxxxxxx>>
>         Content-Type: text/plain; charset="utf-8"
>
>         Hi,
>         You should change the light phase,such as chaning G to r.
>
>         Cellen Fadi <mariacellen@xxxxxxxxxxx
>         <mailto:mariacellen@xxxxxxxxxxx>> ? 2019?3?27? ?? 18:04???
>
>         > hello,
>         >
>         > I would like to change the priority rule at the traffic
>         lights. Like you
>         > see on the picture the green and red phases are wrong . I
>         have tried to
>         > select conflict in NETEDIT but it does not work. Can you
>         help me please.
>         > Thanks!
>         >
>         > best regards
>         > Fadi
>         > _______________________________________________
>         > sumo-user mailing list
>         > sumo-user@xxxxxxxxxxx <mailto:sumo-user@xxxxxxxxxxx>
>         > To change your delivery options, retrieve your password, or
>         unsubscribe
>         > from this list, visit
>         > https://www.eclipse.org/mailman/listinfo/sumo-user
>         >
>         -------------- next part --------------
>         An HTML attachment was scrubbed...
>         URL:
>         <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190327/c873add7/attachment.html>
>
>         ------------------------------
>
>         Message: 2
>         Date: Wed, 27 Mar 2019 12:14:33 +0100
>         From: Jakob Erdmann <namdre.sumo@xxxxxxxxx
>         <mailto:namdre.sumo@xxxxxxxxx>>
>         To: Sumo project User discussions <sumo-user@xxxxxxxxxxx
>         <mailto:sumo-user@xxxxxxxxxxx>>
>         Subject: Re: [sumo-user] Traffic Light
>         Message-ID:
>         ? ? ? ?
>         <CAMbUcby6kWu0n_oRnhDmRV+1s2CdLBhaBj4zFx0EJ0z7VtVu7A@xxxxxxxxxxxxxx
>         <mailto:CAMbUcby6kWu0n_oRnhDmRV%2B1s2CdLBhaBj4zFx0EJ0z7VtVu7A@xxxxxxxxxxxxxx>>
>         Content-Type: text/plain; charset="utf-8"
>
>         You must use the traffic light mode of netedit (hotkey 't') to
>         edit traffic
>         light plans.
>
>         Am Mi., 27. M?rz 2019 um 11:25 Uhr schrieb iCashWave
>         <icashwave@xxxxxxxxx <mailto:icashwave@xxxxxxxxx>>:
>
>         > Hi,
>         > You should change the light phase,such as chaning G to r.
>         >
>         > Cellen Fadi <mariacellen@xxxxxxxxxxx
>         <mailto:mariacellen@xxxxxxxxxxx>> ? 2019?3?27? ?? 18:04???
>         >
>         >> hello,
>         >>
>         >> I would like to change the priority rule at the traffic
>         lights. Like you
>         >> see on the picture the green and red phases are wrong . I
>         have tried to
>         >> select conflict in NETEDIT but it does not work. Can you
>         help me please.
>         >> Thanks!
>         >>
>         >> best regards
>         >> Fadi
>         >> _______________________________________________
>         >> sumo-user mailing list
>         >> sumo-user@xxxxxxxxxxx <mailto:sumo-user@xxxxxxxxxxx>
>         >> To change your delivery options, retrieve your password, or
>         unsubscribe
>         >> from this list, visit
>         >> https://www.eclipse.org/mailman/listinfo/sumo-user
>         >>
>         > _______________________________________________
>         > sumo-user mailing list
>         > sumo-user@xxxxxxxxxxx <mailto:sumo-user@xxxxxxxxxxx>
>         > To change your delivery options, retrieve your password, or
>         unsubscribe
>         > from this list, visit
>         > https://www.eclipse.org/mailman/listinfo/sumo-user
>         >
>         -------------- next part --------------
>         An HTML attachment was scrubbed...
>         URL:
>         <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190327/65e25d65/attachment.html>
>
>         ------------------------------
>
>         Message: 3
>         Date: Wed, 27 Mar 2019 17:25:13 +0800
>         From: Bijal <bijal.varia88@xxxxxxxxx
>         <mailto:bijal.varia88@xxxxxxxxx>>
>         To: Sumo project User discussions <sumo-user@xxxxxxxxxxx
>         <mailto:sumo-user@xxxxxxxxxxx>>
>         Subject: Re: [sumo-user] Convert sumolib.net.readnet Graph to
>         ? ? ? ? Adjacency? ? ? ?Matrix
>         Message-ID:
>         ? ? ? ?
>         <CABbss+jjh3_UpsNGvaRc6Fmic8GWdmVE-T4ucWz2rBpzGoMWSQ@xxxxxxxxxxxxxx
>         <mailto:CABbss%2Bjjh3_UpsNGvaRc6Fmic8GWdmVE-T4ucWz2rBpzGoMWSQ@xxxxxxxxxxxxxx>>
>         Content-Type: text/plain; charset="utf-8"
>
>         Dear Sir,
>
>         I have converted Graph to Adjacency Matrix. But it gives wrong
>         intersection
>         values.
>
>         My problem is i am not able to understand why the value
>         of edge.getToNode().getID() shows u'5' (variable type shows
>         Unicode) in
>         place of Value 5? [Please find photo attached here with]
>
>         I need integer values because i am doing following :
>
>         ? def add_edge(self, u, v, weight=1):
>         ? ? ? ? if u in self.vertices and v in self.vertices:
>         ? ? ? ? ?*?
>         ?self.edges[self.edge_indices[u]][self.edge_indices[v]] =
>         weight*
>         ? ? ? ? ? ?
>         self.edges[self.edge_indices[v]][self.edge_indices[u]] = weight
>         ? ? ? ? ? ? return True
>         ? ? ? ? else:
>         ? ? ? ? ? ? return False
>         Please help me to solve this issue.
>         [image: image.png]
>
>
>         --
>         *:)*
>         Bijal Varia
>         -------------- next part --------------
>         An HTML attachment was scrubbed...
>         URL:
>         <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190327/b8ea9bf3/attachment.html>
>         -------------- next part --------------
>         A non-text attachment was scrubbed...
>         Name: image.png
>         Type: image/png
>         Size: 248841 bytes
>         Desc: not available
>         URL:
>         <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190327/b8ea9bf3/attachment.png>
>
>         ------------------------------
>
>         _______________________________________________
>         sumo-user mailing list
>         sumo-user@xxxxxxxxxxx <mailto:sumo-user@xxxxxxxxxxx>
>         To change your delivery options, retrieve your password, or
>         unsubscribe from this list, visit
>         https://www.eclipse.org/mailman/listinfo/sumo-user
>
>
>         End of sumo-user Digest, Vol 21, Issue 106
>         ******************************************
>
>
>
> --
> *:)*
> Bijal Varia
>
> _______________________________________________
> sumo-user mailing list
> sumo-user@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.eclipse.org/mailman/private/sumo-user/attachments/20190403/86754e8a/attachment.html>

------------------------------

_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user


End of sumo-user Digest, Vol 22, Issue 9
****************************************


--
:)
Bijal Varia

Back to the top