What is an active node in a graph and how can it be identified? - graph

I don't understand exactly what an active node is and how I could identify one, you have an example in the image below
https://i.stack.imgur.com/zJ12z.png
I don't necessarily need a solution, but more of a definition or a good example

The Push-Relabel Maximum Flow Algorithm has the definition:
For a fixed flow f1, a vertex v ∉ {s, t} is called active if it has positive excess with respect to f1, i.e., xf(u) > 0.
If that is the algorithm you are using to analyse the graph then you can use that definition; if you are using a different algorithm then you should consult the definitions for that algorithm and it will tell you how an "active" vertex is defined.

Related

ℝ³ -> ℕ mapping for a finite number of values

I am looking for an algorithm that is capable of mapping a finite but large number of 3 dimensional positions (about 10^11) to indices (so a mapping ℝ³ -> ℕ)
I know that it's possible and fairly simple to make an ℕ -> ℝ³ mapping, and that's essentially what i want to do, but ℕ -> ℝ³ would be an impractical way of figuring out which indices of ℕ are near a certain position,
Ideally i would also like to ensure that my finite subset of ℕ contains no duplicates.
Some background on how this would be implemented to give a better idea on the constraints and problems with some naive solutions to this problem:
I'm trying to think of a way to map stars in a galaxy to a unique ID that i can then use as a "seed" for a random number generator, an ℕ -> ℝ³ mapping would require me to iterate over all of ℕ to find the values of ℝ³ that are near a given location, which is obviously not a practical approach
I've already found some information about the cantor pairing function and dovetailing, but those cause problems because those mainly apply to ℕⁿ and not ℝⁿ.
It's not guaranteed that my ℝ³ values follow a grid, if they did i could map ℝ³-> ℕ³ by figuring out which "box" the value is in in, and then use cantor's pairing function to figure out which ℕ belongs to that box, but in my situations the box might contain multiple values, or none.
Thanks in advance for any help
You could use a k-d tree to spatially partition your set of points. To map onto a natural number, treat the path through the tree to each point as string of binary digits where 0 is the left branch and 1 is the right branch. This might not get you exactly what you're looking for, since some points which are spatially close to each other, may lie on different branches, and are therefore numerically distant from each other. However if two points are close to each other numerically, they will be close to each other spatially.
Alternatively, you could also use an octree, in which case you get three bits at a time for each level you descend into the tree. You can completely partition the space so each region contains at most one point of interest.

Cormen's "Introduction to algorithms" 3rd Edition - Edmonds-karps-Algorithm - Lemma 26.7

since I think many of us don't have the same edition of "Introduction to algorithms" of Prof. Cormen et al., I'm gonna write the Lemma (and my question) in the following.
Edmonds-Karp-Algorithm
Lemma 26.7 (in 3rd edition; in 2nd it may be Lemma 26.8):
If the Edmonds-Karp algorithm is run on a flow network G=(V,E) with source s and sink t, then for all vertices v in V{s,t}, the shortest-path distance df(s,v) in the residual network Gf increases monotonically with each flow augmentation
Proof:
First, suppose that for some vertex v in V{s,t}, there is a flow augmentation that causes the shortest-path distance from s to v to decrease, then we will derive a contradiction.
Let f be the flow just before the first augmentation that decreases some shortest-path distance, and let f' be the flow just afterward. Let v be the vertex with the minimum df'(s,v), whose distance was decreased by the augmentation, so that df'(s,v) < df(s,v). Let p = s ~~> u -> u be a shortest path from s to v in Gf', so that (u,v) in Ef' and
df'(s,u) = df'(s,v) - 1. (26.12)
Because of how we chose v, we know that the distance of vertex u from soruce s did not decrease, i.e.
df'(s,u) >= df(s,u). (26.13)
...
My question is: I don't really understand the phrase
"Because of how we chose v, we know that the distance of vertex u from soruce s did not decrease, i.e.
df'(s,u) >= df(s,u). (26.13)"
How does the way we chose v affect the property that "the distance of vertex u from s did not decrease" ? How can I derive the equation (26.13).
We know, u is a vertex on the path (s,v) and (u,v) is also a part in (s,v). Why can (s,u) not decrease as well?
Thank you all for your help.
My answer may be drawn out, but hopefully it helps for an all around understanding.
For some history, note that the Ford-Fulkerson algorithm came first. Ford-Fulkerson simply selects any path from the source to the sink, adds the amount of flow to the current capacity, then augments the Residual graph accordingly. Since the path that is selected could hypothetically be anything, there are scenarios where this approach takes 'forever' (figuratively and literally speaking, if the edge weights are allowed to be irrational) to actually terminate.
Edmonds-Karp does the same thing as the Ford-Fulkerson, only it chooses the 'shortest' path, which can be found via a breadth-first search (BFS).
BFS guarantees a certain (partial) ordering among the traversed vertices. For example, consider the following graph:
A -> B -> C,
BFS guarantees that B will be traversed before C. (You should be able to generalize this argument with more sophisticated graphs, an exercise I leave to you.) For the remainder of this post, let "n" denote the number of levels it takes in BFS to reach the target node. So if we were searching for node C in the example above, n = 2.
Edmonds-Karp behaves similarly to Ford-Fulkerson, only it guarantees that the shortest paths are chosen first. When Edmonds-Karp updates the residual graph, we know that only nodes at a level equal to or smaller than n have actually been traversed. Similarly, only edges between nodes for the first n levels could have possibly been updated in the residual graph.
I'm pretty sure that the 'how we chose v' reflects the ordering that BFS guarantees, since the added residual edges necessarily flow in the opposite direction of any selected path. If the residual edges were to create a shorter path, then it would have been possible to find a shorter path than n in the first place, because the residual edges are only created when a path to the target node has been found and BFS guarantees that the shortest such path has already been found.
Hope this helps and at least gives some insight.
I don't quite understand either. But I think that "how we choose v" here means that the flow augmentation only causes the path from s to v becomes shorter, in another way, v is the first node whose path from s becomes shorter because of the augmentation, thus the node u's distance from s does not become shorter.

Graph Edges Deletion

We are given a undirected graph without loops.We have to check if it is possible to delete edges such that the degree of each vertex is one.
What should I try to this question? Should I use adjacency matrix or list.
Please suggest me the efficient way.
If the graph needs to be fully connected, it's possible if and only if
there are exactly two vertices and they have an edge between them.
If it does not need to be fully connected you must search for a
similar constellation. That is, you need to see if it is possible to
partition the graph into pairs of vertices with one edge in each
pair. That is what we are after. What do we know?
The graph has no loops. This means it must be a tree! (Not necessarily
binary, though). Maybe we can solve this eagerly by starting at
the bottom of the tree? We don't know what the bottom is; how do we
solve that? We can decide this ourselves, so I decide to pick all the
leaves as "bottom".
I now propose the following algorithm (whose efficiency you may
evaluate yourself, it isn't necessarily the best algorithm):
For each leaf L:
Let P be the parent of L, and Q the parent of P (Q may be NULL).
Is the degree of P <= 2? That is, does it have only one edge
connecting it to L, and possibly one connecting it to Q?
If no: Pick another leaf L and go to 1.1.
If yes: L and P can form a pair by removing the edge between P and Q. So
remove L and P from your memory (in some way; let's come back to
data structures later).
Do we have any vertices left in the graph?
No: The answer is "Yes, we can partition the graph by removing edges".
Only one: The answer is "No, we cannot partition the graph".
More:
Did we remove any nodes?
If yes: Go back to 1 and check all the current leaves.
If no: The answer is "No, we cannot partition the graph".
So what data structure do you use for this? I think it's easiest to
use a priority queue, perhaps based on a min-heap, with degree as
priority. You can use a linked list as a temporary storage for leaves
you have already visited but not removed yet. Don't forget to decrease
the priority of Q in step 1.2.2.
But you can do even better! Add all leaves (vertices with degree 1) to
a linked list. Loop through that list in step 1. In step 1.2.2, check
the degree of Q after removing L and P. If the degree is 1, add it to
the list of leaves!
I believe you can implement the entire algorithm recursively as well, but I let you
think about that.

Union-Find algorithm and determining whether an edge belongs to a cycle in a graph

I'm reading a book about algorithms ("Data Structures and Algorithms in C++") and have come across the following exercise:
Ex. 20. Modify cycleDetectionDFS() so that it could determine whether a particular edge is part of a cycle in an undirected graph.
In the chapter about graphs, the book reads:
Let us recall from a preceding section that depth-first search
guaranteed generating a spanning tree in which no elements of edges
used by depthFirstSearch() led to a cycle with other element of edges.
This was due to the fact that if vertices v and u belonged to edges,
then the edge(vu) was disregarded by depthFirstSearch(). A problem
arises when depthFirstSearch() is modified so that it can detect
whether a specific edge(vu) is part of a cycle (see Exercise 20).
Should such a modified depth-first search be applied to each edge
separately, then the total run would be O(E(E+V)), which could turn
into O(V^4) for dense graphs. Hence, a better method needs to be
found.
The task is to determine if two vertices are in the same set. Two
operations are needed to implement this task: finding the set to which
a vertex v belongs and uniting two sets into one if vertex v belongs
to one of them and w to another. This is known as the union-find
problem.
Later on, author describes how to merge two sets into one in case an edge passed to the function union(edge e) connects vertices in distinct sets.
However, still I don't know how to quickly check whether an edge is part of a cycle. Could someone give me a rough explanation of such algorithm which is related to the aforementioned union-find problem?
a rough explanation could be checking if a link is a backlink, whenever you have a backlink you have a loop, and whenever you have a loop you have a backlink (that is true for directed and undirected graphs).
A backlink is an edge that points from a descendant to a parent, you should know that when traversing a graph with a DFS algorithm you build a forest, and a parent is a node that is marked finished later in the traversal.
I gave you some pointers to where to look, let me know if that helps you clarify your problems.

What is a "graph carving"?

I've faved a question here, and the most promising answer to-date implies "graph carvings". Problem is, I have no clue what it is (neither does the OP, apparently), and it sounds very promising and interesting for several uses. My Googlefu failed me on this topic, as I found no useful/free resource talking about them.
Can someone please tell me what is a 'graph carving', how I can make one for a graph, and how I can determine what makes a certain carving better suited for a task than another?
Please don't go too mathematical on me (or be ready to answer more questions): I understand what's a graph, what's a node and what's a vertex, I manage with big O notation, but I have no real maths background.
I think the answer given in the linked question is a little loose with terminology. I think it is describing a tree carving of a graph G. This is still not particularly google-friendly, I admit, but perhaps it will get you going on your way. The main application of this structure appears to be in one particular DFS algorithm, described in these two papers.
A possibly more clear description of the same algorithm may appear in this book.
I'm not sure stepping through this algorithm would be particularly helpful. It is a reasonably complex algorithm and the explanation would probably just parrot those given in the papers I linked. I can't claim to understand it very well myself. Perhaps the most fruitful approach would be to look at the common elements of those three links, and post specific questions about parts you don't understand.
Q1:
what is a 'graph carving'
There are two types of graph carving: Tree-Carving and Carving.
A tree-carving of a graph is a partition of the vertex set V into subsets V1,V2,...,Vk with the following properties. Each subset constitutes a node of a tree T. For every vertex v in Vj, all the neighbors of v in G belong either to Vj itself, or to Vi where Vi is adjacent to Vj in the tree T.
A carving of a graph is a partitioning of the vertex set V into a collection of subsets V1,V2,...Vk with the following properties. Each subset constitutes a node of a rooted tree T. Each non-leaf node Vj of T has a special vertex denoted by g(Vj) that belongs to p(Vj). For every vertex v in Vi, all the neighbors of v that are in ancestor sets of Vi belong to either
Vi or
Vj, where Vj is the parent of Vi in the tree T, or
Vl, where Vl is the grandparent in the tree T. In this case, however the neighbor of v can only be g(p(Vi))
Those defination referred from chapter 6 of book "Approximation Algorithms for NP-Hard problems" and paper1. (paper1 is picked from Gain's answer, thanks Gain.)
According to my understanding. Tree-Carving or Carving are a kind of representation (or a simplification) of an original graph G. So that the resulting new graph still preserve 'connection properties' of G, but with much smaller size(less vertex, less nodes). These two methods both somehow try to delete 'local' 'similar' information but to keep 'structure' 'vital' information. By merging some 'closed' vertices into one vertex and deleting some edges.
And It seems that Tree Carving is a little bit simpler and easier to understand Since in **Carving**, edges are allowed to go to a single vertex in the grapdhparenet node as well. It would preserve more information.
Q2:
how I can make one for a graph
I only know how to get a tree-carving.
You can refer the algorithm from paper1.
It's a Depth-First-Search based algorithm.
Do DFS, before return from an iteration, check whether this edges is 'bridge' edge or not. If yes, you need remove this 'bridge' and adding some 'back edge'.
You would get a DFS-partition which yields a tree-carving of G.
Q3:
how I can determine what makes a certain carving better suited for a task than another?
Sorry I don't know. I am also a new guy in graph theory.
If you have more question:
What's g function of g(Vj)?
a special node called gray node. go to paper1
What's p function of p(Vj)?
I am not sure. maybe p represent 'parent'. go to paper1
What's the back edge of node t?
some edge(u,v) s.t. u is a decent of t and v is a precedent of t. goto to paper1
What's bridge?
bridge wiki

Resources