Sample algorithm to "linearize" a graph -
simplifying business example, have following situation:
some objects should distributed in graph in "linear" way possible given "thermometer".
say, voyager visits cities. several cities visited multiple times.
so, have list of cities in ordinate axis (that may duplicated), , time in abscissas one.
now, given path, (a => x => => b => c) should display line, in "most linear way possible".
by eg. in image above, green line optimal one
(1 > 2 > 3 > 4 > 5)
but there multiple possible outputs
(1 > 2 > 1 > 4 > 5)
(1 > 2 > 3 > 4 > 5)
(1 > 2 > 6 > 4 > 5)
(3 > 2 > 1 > 4 > 5)
(3 > 2 > 3 > 4 > 5)
(3 > 2 > 6 > 4 > 5)
(6 > 2 > 1 > 4 > 5)
(6 > 2 > 3 > 4 > 5)
(6 > 2 > 6 > 4 > 5)
is there algorithms helping in such situations?
construct graph node pairing of city+value , time (e.g. a(3)/1). edge exists between 2 nodes adjacent in path (e.g. a(3)/1 x(2)/2).
the weight of edge difference in vector (the opposite angle) between last pair of nodes , next pair of nodes (this make edge weight dynamic depending on came from). use dijkstra find minimum distance (a) goal.
example graph (edges given in degrees , estimates):
total cost 0 0 105 15 a31 -> x22 -> a13 -> b44 -> c55 120 90 0 0 -> a33 -> b44 -> c55 90 115 110 105 -> a63 -> b44 -> c55 330
Comments
Post a Comment