For a graph G = (V, E) we denote the length of the shortest path between
vertices u, v ∈ V by dG(u, v). The diameter of G is defined as ∆(G) = maxu,v∈V dG(u, v). A pair of vertices (u, v) that realizes the diameter is called a farthest pair.
Let u be any vertex of G and let v be a vertex that is farthest away from u
in G (i.e. maximizes dG(u, v)). Prove that, if G is an undirected tree, then v is part of a farthest pair of G.
That is the question and I have to do the prove. I assumed that there is a existence of a farthest pair (x, y) such that dG(u, v), dG(x, v), and dG(y, v) are smaller than dG(x, y). I'm trying to find a contradition out of it, by assuming that v is not a farthest pair of G.
If v is part of the farthest pair of G:
There exist a v' such that Dg(v, v') >= Dg(X, Y)
If v is not part of the farthest pair of the, we negate the statement above. Using De Morgan, we get:
For all v': not( Dg(v, v') >= Dg(X, Y) ).
For all v': Dg(v, v') < Dg(X, Y).
So now I have three statements
(x,y) is the farthest pair.
For all v': Dg(v, v') < Dg(X, Y).
v is the furthest from u.
How do I continue with the prove to prove what has to be proven?
(if G is an undirected tree, then v is part of a farthest pair of G.)
Your question is actually an exact duplicate of https://math.stackexchange.com/questions/1209922/furthest-distance-vertices-undirected-tree
Related
I have an array of vertices that together form a polygon which can either be a convex or concave polygon. Each vertex obviously has x and y values. Knowing the leftmost vertex (which as I understand would always be a concave point), how can I iterate through the remaining points to determine whether each is convex or concave?
A leftmost point must be convex.
Call that vertex V, the previous one is U and the next one is W.
Find the vectors a = U - V and b = W - V. Now compute z = ax * by - ay * bx
and note the sign of z.
(This is the z component of the cross product [a 0] X [b 0]. The sign says whether going from U to V to W is a "left turn" or "right turn" in the 2D plane.)
Then continue around the polygon. At each vertex do the same computation where V is the current vertex, U the previous one, and W the next. If the result has the same sign as the first, it's concave, else convex.
For a given undirected graph G=(V,E) I'm trying to construct a Boolean polynomially computable formula ϕ with the following property: ϕ is satisfiable iff vertices of G can be colored in 3 colors with the following condition: For any edge (u, v) ∈ E, if u and v have different colors, then there exists w ∈ V such that (u, w) ∈ E, (v, w) ∈ E, and w has the third color (different from both u and v). Here it is ok
that two vertices of the same color may be connected by an edge.
So I need that all nodes must get a color (3 expression) + no nodes can get more than one color (9 expressions) + ... here I'm in trouble. Thank you for your help.
The problem is finding the minimum edit distance between two graphs with no edges, considering there might be different costs for adding, removing or replacing vertices.
I was told this distance is a metric, and there is a easy way to prove it. Is it so? How it can be done?
I will call the distance between two graphs G and H, d(G, H).
For any graph G, d(G, G) = 0. As long as all the costs are strictly positive, then for any G != H, d(G, H) > 0. So non-negativity is satisfied.
As long as the cost of removing a vertex is the same as the cost of adding a vertex, for any two graphs G, H, d(G, H) = d(H, G). So symmetry is satisfied.
Finally, for any three graphs G, H, K, d(G, K) is at most d(G, H) + d(H, K) because one could edit G to K by first editing it to H.
The above criteria define a metric.
I'd like to implement finite, directed graphs in Idris. Also I want to work with vertex maps f : V -> X from the vertex set to some other type / set. Which would be the most natural approach here?
One option is to always chose Fin n for the vertex set. This way, a graph can be straightforwardly implemented as its adjacency matrix, i.e. Graph n = Vect n (Vect n Bool), and any vertex map as vector of type Vect n a.
On the other hand, I like the idea of defining Graph a = SortedMap (a, a) Bool. This way, a few constructions seem more straightforward, e.g. the graph product of type Graph a -> Graph b -> Graph (a, b).
But it is possible then to construct maleficent graph instances, where e.g. (x, y) is a key of g but (y, x) is not. Also, if I want to write a function which takes a graph and a compatible vertex map, I don't know how to specify that the domains of both objects have to coincide. Possibly f : (g : Graph a) -> (m : SortedMap a b) -> {auto p : vertexList g = keys m} -> ... where the functions vertexList and keys have to be written first?
A third definition would be Graph a = (a, a) -> Bool where a is supposed to be some finite type like Fin n or (Fin m, Fin n). Then vertex maps would simply be of type a -> b.
Could someone explain to me the following definition of a vertex cover??
A vertex cover of G=(V,E), an undirected graph, is a subset $S\subseteq V$ such that each edge of G is incident upon some vertex in S.
You can think of a vertex cover as a set of vertices S so that every edge e in E has an endpoint in S (that's just rephrasing the definition). As an example, if your graph is a star (one central vertex v, and n leaves, w_1, w_2, ..., w_n) with edges {v, w_i} for i from 1 to n. A vertex cover could be any of the following:
S_1 = {v} because every edge contains v
S_2 = {w_1, w_2, ..., w_n}
S_3 = V
or just any subset of vertices containing v.