The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998 The.Algorithm.Design.Manual.Springer-Verlag.1998

18.04.2013 Views

Modeling Graph Problems fragment r forced to be to the right of f. We seek an ordering of the vertices such that all the edges go from left to right. This is exactly a topological sort of the resulting directed acyclic graph. The graph must be acyclic for this to work, because cycles make finding a consistent ordering impossible. ● ``In my graphics work I need to solve the following problem. Given an arbitrary set of rectangles in the plane, how can I distribute them into a minimum number of buckets such that the subset of rectangles in the same bucket do not intersect each other? In other words, there should not be any overlapping area between any two rectangles in the same bucket.'' We can formulate a graph where each vertex is a rectangle, and there is an edge if two rectangles intersect. Each bucket corresponds to an independent set of rectangles, so there is no overlap between any two. A vertex coloring of a graph is a partition of the vertices into independent sets, so minimizing the number of colors is exactly what you want. ● ``In porting code from UNIX to DOS, I have to shorten the names of several hundred files down to at most 8 characters each. I can't just take the first eight characters from each name, because ``filename1'' and ``filename2'' will get assigned the exact same name. How can I shorten the names while ensuring that they do not collide?'' Construct a graph with vertices corresponding to each original file name for , as well as a collection of acceptable shortenings for each name . Add an edge between each original and shortened name. Given such a formulation, we seek a set of n edges that have no vertices in common, because the file name of each is thus mapped to a distinct acceptable substitute. Bipartite matching, discussed in Section , is exactly this problem of finding an independent set of edges in a graph. ● ``In organized tax fraud, criminals submit groups of phony tax returns in the hopes of getting undeserved refunds. These phony returns are all similar, but not identical. How can we detect clusters of similar forms so the IRS can nail the cheaters?'' A natural graph model treats each form as a vertex and adds an edge between any two tax forms that are suspiciously similar. A cluster would correspond to a group of forms with many edges between them. In particular, a clique is a set of k vertices with all possible edges between them. Any sufficiently large clique identifies a cluster worth studying. ● ``In the optical character-recognition system that we are building, we need a way to separate the lines of text. Although there is some white space between the lines, problems like noise and the tilt of the page makes it hard to find. How can we do line segmentation? Consider the following graph formulation. Treat each pixel in the image as a vertex in the graph, with an edge between two neighboring pixels. The weight of this edge should be proportional to how dark the pixels are. A segmentation between two lines is a path in this graph from the left to right side of the page. Of all possible paths, we seek a relatively straight path that avoids as much blackness as possible. This suggests that the shortest path in the pixel graph will likely find a file:///E|/BOOK/BOOK2/NODE72.HTM (2 of 3) [19/1/2003 1:29:12]

Modeling Graph Problems good line segmentation. Next: Minimum Spanning Trees Up: Graph Algorithms Previous: Articulation Vertices Algorithms Mon Jun 2 23:33:50 EDT 1997 file:///E|/BOOK/BOOK2/NODE72.HTM (3 of 3) [19/1/2003 1:29:12]

Modeling Graph Problems<br />

fragment r forced to be to the right of f. We seek an ordering of the vertices such that all the edges<br />

go from left to right. This is exactly a topological sort of the resulting directed acyclic graph. <strong>The</strong><br />

graph must be acyclic for this to work, because cycles make finding a consistent ordering<br />

impossible.<br />

● ``In my graphics work I need to solve the following problem. Given an arbitrary set of rectangles<br />

in the plane, how can I distribute them into a minimum number of buckets such that the subset of<br />

rectangles in the same bucket do not intersect each other? In other words, there should not be any<br />

overlapping area between any two rectangles in the same bucket.''<br />

We can formulate a graph where each vertex is a rectangle, and there is an edge if two rectangles<br />

intersect. Each bucket corresponds to an independent set of rectangles, so there is no overlap<br />

between any two. A vertex coloring of a graph is a partition of the vertices into independent sets,<br />

so minimizing the number of colors is exactly what you want.<br />

● ``In porting code from UNIX to DOS, I have to shorten the names of several hundred files down to<br />

at most 8 characters each. I can't just take the first eight characters from each name, because<br />

``filename1'' and ``filename2'' will get assigned the exact same name. How can I shorten the<br />

names while ensuring that they do not collide?''<br />

Construct a graph with vertices corresponding to each original file name for , as well<br />

as a collection of acceptable shortenings for each name . Add an edge between each<br />

original and shortened name. Given such a formulation, we seek a set of n edges that have no<br />

vertices in common, because the file name of each is thus mapped to a distinct acceptable<br />

substitute. Bipartite matching, discussed in Section , is exactly this problem of finding an<br />

independent set of edges in a graph.<br />

● ``In organized tax fraud, criminals submit groups of phony tax returns in the hopes of getting<br />

undeserved refunds. <strong>The</strong>se phony returns are all similar, but not identical. How can we detect<br />

clusters of similar forms so the IRS can nail the cheaters?''<br />

A natural graph model treats each form as a vertex and adds an edge between any two tax forms<br />

that are suspiciously similar. A cluster would correspond to a group of forms with many edges<br />

between them. In particular, a clique is a set of k vertices with all possible edges between them.<br />

Any sufficiently large clique identifies a cluster worth studying.<br />

● ``In the optical character-recognition system that we are building, we need a way to separate the<br />

lines of text. Although there is some white space between the lines, problems like noise and the tilt<br />

of the page makes it hard to find. How can we do line segmentation?<br />

Consider the following graph formulation. Treat each pixel in the image as a vertex in the graph,<br />

with an edge between two neighboring pixels. <strong>The</strong> weight of this edge should be proportional to<br />

how dark the pixels are. A segmentation between two lines is a path in this graph from the left to<br />

right side of the page. Of all possible paths, we seek a relatively straight path that avoids as much<br />

blackness as possible. This suggests that the shortest path in the pixel graph will likely find a<br />

file:///E|/BOOK/BOOK2/NODE72.HTM (2 of 3) [19/1/2003 1:29:12]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!