Clarification of Graph Terminology - graph

I'm working on a homework question and I've got the answer, but I'm not sure if the terminology I'm using is correct and I was hoping if someone can clarify. Here's the situation:
I have a graph in the shape of a rectangle of size M x N. The node at (0, 0) has no incoming edges. All other nodes have incoming edges from the north, northwest, and west, unless they are on the top or left-most side, in which case the diagonal incoming edge does not exist and either the edge from the west or north does not exist.
So if starting at node (0, 0) and following any path to its finish, it will end at node (m, n). I am now asked to define what type of graph this is. Is this a directed acyclic graph?

Yep, it is, because each edge has a direction (hence directed) and there are no cycles - once you leave any node, there's no way to get back to it by following the edges of the graph (hence acyclic). See http://en.wikipedia.org/wiki/Directed_acyclic_graph for more info.

Related

Easy way to find a graph edge between graph vertexes

if there are 100 graph vertexes, each graph vertex has 4 graph edges toward another graph vertex, and are stored in an array, X. "X(100, 4)" is the array's size, while "X(38, 2)" means the contents of the array at two dimensional index 38, 2.
Is there any simple way to find a way form a given starting graph vertex to another given graph vertex?
It does not have to be the shortest wat, as long as the destination can be reached.
Thanks!
Yes. This is the same as finding a path between two vertices in an undirected graph, and is a thoroughly studied concept in mathematics and computer science. The usual method is a "Depth First Search" (DFS). A suitable algorithm is described here.
Essentially it follows this pattern:
Start with x equal to the start node.
If x is the end node, then we're done.
If we've already visited x then abandon this path.
For each of the nodes y connected to x,
Add x to the current path and set y=x.
Run algorithm from step 2.
Loop to step 4.
That will explore every possible path from x, going as deep down each branch as possible to find the goal or a deadend. Hence "depth first".

Recursive node traversal go through whole graph?

I'm trying to solve this work problem, but I'm having some difficuly, since I suck at recursion.
My question is: is there a way where I can pick a node in a graph and traverse the graph all the way through back to the same node where I started, but the nodes can only be visited once? And of course to save the resulting edges traversed.
The graph is unweighted, but it is coordinates in a 2D x and y coordinate system, so each coordinate has an x and y value, meaning the edges can weighted by calculating the distance between the coordinates. If that helps...
I'm not completely sure I understand, but here is a suggestion: pick a node n0, then an edge e=(n0,n1). Then remove that edge from the graph, and use a breadth-first search to find the shortest path from n1 back to n0 if it exists.
Another suggestion, which might help you to control the length of the resulting path better: Pick a starting node n0 and find a spanning tree T emanating from n0. Remove n0, and T will (hopefully) break into components. Find an edge e=(n1,n2) from one component to another. Then that edge, plus the edges in T connecting the n1 to n0, plus the edges in T connecting n2 to n0, is a cycle with the properties you desire.

forbidden paths in a graph

We are provided with a directed graph (data flow graph). We want to forbid the data from reaching some nodes of the graph, which means we will have forbidden paths to delete but must keep the graph connected.
I propose a simple example to make the problem clear:
Let us have the following graph:
A ------>B-------->C-------->D
I want to forbid data from reaching the node C, so the edge B-C will be removed. At the same time I want the data to reach D. So a new edge from B-D will be created.
Is there an efficient algorithm for the above task?
Thank you.
Every node X that is not allowed to be reached has i incoming edges and j outgoing edges. As we talk about a data-flow graph it is not sufficient for a node before X to only reach one of the j nodes after X. Either you can insert a dummy (Steiner) node X' that has no function except for not being labeled X where you send all i edges and also connect the j outgoing edges. Otherwise you might have to connect every node where one of the i incoming edges originates and connect it to all j nodes where the outgoing edges of X lead. (Otherwise the data flow is broken.)
To repair one to one node is a constant time operation, but repairing all relations for one such node X takes O(i*j) time, i.e., it is quadratic in the number of incident edges.
Data from a,b, and c flows to X and from there to either x,y, or z.
Thus, data from a can reach x,y, and z.
To remove the edge from a->X we have to add edges from a to all nodes that are reachable from X. Since we have to do this for every edge that reaches X we get a quadratic complexity.
EDIT: (Due to the comment) For two forbidden nodes X and Y were there is an edge form X to Y, such an edge can stay. After all edges to all forbidden nodes (except from a forbidden node) are removed the forbidden nodes may form connected components of size > 1. This is not a problem as every such connected component contains only forbidden nodes and edges and can not be reached from the remaining flow-graph.
After this, we only remove edges that lead from a valid node to a forbidden node. These edges have to be removed in order to fulfil the demand. No other edge is removed, thus this is the minimum amount that fulfils the request. (I don't think there is much else to prove here.)

How to identified face from line drawing?

A line drawing is like a graph but its vertices have x,y position. There are no crossing edges. For example, a line drawing like this is a line drawing with 13 vertices numbered by 0-12. A face is a cycle that doesn't have a path that 'inside' it. Faces in the example would be
(0,1,3,2,0), (2,3,5,4,2), (4,5,8,7,4), (7,8,12,11,7) and (0,2,4,7,11,10,9,6,0)
The cycle (0,1,3,5,4,2,0) is NOT a face because there is a path that located inside it, named (2,3). Cycle (0,1,3,5,8,12,11,10,9,6,0) is also NOT a face because there is a path (0,2,4,7,11), located inside it. What algorithm can I use to identify faces like the ones in the example?
Assume all your edges are line segments; every planar graph can be drawn using only line segments. Also assume the graph is connected. Now the algorithm is pretty simple:
Construct a directed graph, such that the vertices are same as in the original graph and there's two directed edges for every original edge, one in each direction
Start with a random (directed) edge that's not been used yet. At its end, choose the next outgoing edge clockwise (or counterclockwise will do as well, just always the same). To decide which edge that is, you'll have to compute from the coordinates of vertices in the planar embedding. You'd better precompute this edge order for each vertex beforehand.
Keep doing that with the end of the selected edge, until you reach the starting vertex. At that point, you've completed a face.
When there's no unused edges, you've found all faces in the graph
Or, use a library like Boost, that has an efficient implementation of such task

Name for graph where disc connecting two points contains no other points?

The problem is the following:
Given is a set of points P on a 2-dimensional plane.
Each with two points (p, q) are connected by an edge, if a circle with the diameter pq exists, which does NOT contain any other points from P and if p and q are on the circumcircle. (so p and q are the ending points of the diameter of the circle)
Does anyone know what the name of this type of graph is?
This is called a Gabriel graph.
I didn't know this before this question. It sounded related to the Delaunay triangulation and a little searching turned up the name pretty quickly. Interestingly, the Gabriel graph is a subgraph of the Delaunay triangulation.
Well, its definitely a planar graph because according to this definition, because there is no way two edges could be intersecting. If this happened then at least one of the end points would be contained in the circle defined by the other edges. To prove this you would probably do a proof by contradiction (assume there exists two edges e1 and e2 which intersect). Though Ill leave the proof as an exercise for the OP (because this kind of sounds like homework).

Resources