How can we solve single source destination graph with dijkstra? - dijkstra

I have a single destination and multiple sources and i want to go through all of the nodes, but here is the case of having single destination and multipe sources how can i solve this?
is there any way to modify it? may be i need jhonsons algorithm.

You can reverse all the edges from destination to the source.then you can apply dijkstra algorithm. you dont need jhonsons algorithm.

Related

Calculate route using only specified routes with HERE

I want to calculate a route from A to B using only a subset of the routes available in a city, as long as it is possible (if A or B is not on the subset of roads I still need to calculate the route). I tried to use avoidareas but it's quite difficult to define rectangles to avoid outside of the roads (and I saw somewhere the number of boxes is limited).
Can you please explain what do you mean by "subset of the routes". Do you mean to avoid a particular kind of road?
if you want to always include a certain road(s) you can always use waypoints to direct the route through those roads. Generally, Routing algorithms are designed to "avoid" not "prefer" an area.
Various examples on how to avoid a rectangle(s) is explained here- https://developer.here.com/documentation/routing/topics/example-route-avoiding-an-area.html
How to use a waypoint is explained here - https://developer.here.com/documentation/routing/topics/resource-param-type-waypoint.html
How to avoid a certain road type is explained here - https://developer.here.com/documentation/routing/topics/avoiding-certain-road-types.html

Using node similarities in a graph or clustering viaualization

Use case:
nodes are documents
Links are links between documents that have an associated correlation (e.g., 0 to 1)
Being new, it is not clear how to apply those correlations or "weights' so that the document cluster in a logical manner.
Can anyone point me to an existing example?
Thanks in advance.
Positioning nodes is done by the layout. Use any force-directed (physics) layout, like CoSE or Cola. Those layouts allow your to specify how strongly nodes should be pulled towards one another on a per-edge basis.
Try some of the force-directed layouts to see which one gives results that you like. Each one has different trade-offs (speed, aesthetics, etc.).
Just make sure to set the edge force for whatever layout, e.g. edgeElasticity for CoSE, to be proportional to edge.data('weight').
Example: http://js.cytoscape.org/demos/7b511e1f48ffd044ad66/

Given a OSM node id, how do I find the previous x points in all directions?

I have a OSM node Id/ latitude-longitude for a point in the road(say point Z). How do I find the previous x points that I need to travel to reach Z in all directions? I was thinking overpass API could help me. But it is able to return points only with tags. I am not able to get it return the node Ids on the road/way.
Can you please suggest any API/tutorial that could help?
if i'm not wrong what you are asking is: given a osm node id with coordinate x and y what are all points to do in order to arrive there from a starting point?
if this is the question well this is a graph oriented question; you should create a grah and then use some algorithm in order to find all the routes between starting point and end point; you should use some graph oriented software.. something like neo4j and spatial contrib (https://github.com/neo4j-contrib/spatial)
In past i built a project where i read an osmfile, create a graph and used A* algorithm; you may give to it a look https://github.com/angeloimm/neo4jAstarTest
I suggest to get started by reading about OSM elements, especially nodes and ways. Afterwards take a look at OSM XML format. It might also help to open an OSM editor (e.g. iD) and to take a look at the raw data.
Nodes don't have any order or "next node" themselves. Nodes can be part of one or multiple ways. Each way references a list of ordered nodes. So you have to look at all ways a node belongs to, then look at the way's node list to determine the previous and next nodes. If the node is at the start or end of a way then you have to look if there are one or more consecutive ways. Consecutive ways share the same node at their start/end.

Any way to find all incoming edges to a node in a directed graph?

I'm trying to add up the weights of all the incoming edges to a node("mynode") in a directed graph (digraph). How do I do it efficiently?
One way is to use findedge(s,mynode) by trying all the nodes in place of s, and if it exists, add the weight.
But this is really inefficient if I have a sparse matrix. What else can I do? I was hoping for something like findedge(:, mynode).
Found it, use the predecessor() function to to find the predecessors. Now you dont have to check every node of the graph.

Matlab: Publish figures in a sequence

Kindly consider the published output in the attached image. Is it possible to arrange figures in a order, say for example: figure below one another? I searched, but couldn't resolve it.
Thanks
You could/should use "snapnow" instead of creating figures to get pictures in a well-defined order.