Pick maximum number of vertices to make graph empty - graph

I have an undirected graph G. Each time I want to pick a node v and remove all its neighbors from G. I want to pick the maximum number of vs until G becomes empty.
For example, given three-node graph A -- B -- C. The optimal strategy is to pick A and C. The worst strategy is to pick B only.
My first attempt is brute-force, but its time complexity is apparently 2 to the power of the number of vertices, too high. Is there any polynomial algorithm to reach the goal?
Constraint: the number of edges is less than 10% of the number of vertices.
Thanks in advance!

Related

Maximum number of directed graph

Given set of N points, what is the maximum number of directed graphs can be created ? I'm having trouble with isomorphic problem.
Edit (1): Only directed simple, non-loop vertex graph, doesn't required to be connected
Edit (2): Any point in this set is treated equally to each other, so the main problem here is to calculate and subtract the number of isomorphic graphs created from different sets of edges.
Number of unlabeled directed graphs with n vertices is here (OEIS A000273)
1, 1, 3, 16, 218, 9608, 1540944, 882033440, 1793359192848
There is no closed formula, approximated value is number of labeled graphs divided by number of vertex permutations:
2^(n*(n-1)) / n!
There are n-1 possible edges for each node, so a total of n(n-1) edges.
Each possible graph will either contain a particular edge, or it won't.
So the number of possible graphs is 2^(n(n-1)).
EDIT: This only applies under the assumption there are no loops and each edge is unique.
Looping is basically coming back to the same node again so I'm considering double-headed arrows are not allowed. Now, if there are n nodes available so graphs you make without loops can have n-1 edges. Now, let m be the number of homeomorphic graphs you can make out of n nodes. Let si is number of symmetries present in ith graph of those m homeomorphic graphs. These symmetries I'm talking about are the likes of we study in group theory for geometric figures. Now, we know all edge can have 2 states i.e. left head and right head.
So the total number of distinct directed graphs can be given as:
Note: If these symmetries were not present then it would have been simply m*2(n-1)
(Edit 1) Also, this valid for connected graph with n nodes. If you want to include graphs that don't need to be connected then you'll have to modify a few things in this equation or add few things like the number of smaller partitions of this n noded graph you can form and apply this formula in each of those combinations.
Permutation&Combination, Group Theory, Symmetries, Partitions, Overall it's messy so this was the only simple way I could put it.

Finding the maximum number of vertex disjoint from source to destination

I am aware that the problem has been discussed here more than once. However, I need to find the maximum number K of vertex-disjoint paths in a directed graph with a running time of |V| x |E|.
I know the algorithm of transforming each vertex into v_in, v_out and adding an edge with capacity 1 from v_in to v_out and for each pair of vertices (u,v) add an edge with capacity 1 from u_out to v_in and then compute the max flow in this network. However, after my calculations this algorithm takes O(E) preprocessing + O(VE^2) or O(V^2E) for max flow. Am I doing something wrong?
Use James B Orlin's + KRT (King, Rao, Tarjan)'s algorithm instead of Ford Fulkerson to calculate flow and it'll be O(V*E). (See https://en.wikipedia.org/wiki/Maximum_flow_problem)

Number of broadcasts to allow 95% of node pairs to exchange in directed graph

I have a directed unweighted graph with N nodes and E edges. Nodes are of an average degree 2E/N.
In the first round, nodes each broadcast their information to all their neighbours. In subsequent rounds, nodes broadcast the information received from their neighbours during the previous round to all other neighbours, and so forth.
The graph is not guaranteed to be acyclic.
My question is: how many consecutive rounds of broadcast are required, on average, for 95% of node pairs to have reached one another? Is it possible to calculate an approximate figure based on the average degree of the graph?
By average, I assume you mean average over all possible (N,E) directed graphs with no multiple edges.
Theorem 1
If E <= (N-1)^2, there will be at least one graph where information won't propagate.
Proof
A directed graph with N nodes has up to N(N-1) edges. Consider a complete graph, select a node, and remove all its outgoing edges (Alternatively, we can remove all its incoming edges). Information from this node cannot propagate, and we are left with N(N-1)-(N-1) = (N-1)^2 edges.
Corollary 1
When E <= (N-1)^2, there is at least one graph where information cannot propagate, therefore the average number of rounds is infinite.
Theorem 2a
If E > (N-1)^2 the maximal number of rounds is 2.
Proof
A directed graph with N nodes and E > (N-1)^2 edges is a complete graph where up to (N-2) edges removed.
If we want to remove edges from a complete graph such the the number of rounds will be 3 (e.g. from node A to node B), we'll need to make sure there is no node B and edges A->B and B->C. This means that we need to remove at least one edge (either A->B or B->C) for each of the (N-2) possible 'B' nodes. We also need to remove the direct A->C edge. In total we need to remove (N-3) edges.
Theorem 2b
If E > (N-1)^2 the minimal number of rounds is 2.
Proof
Trivial. The graph is incomplete, therefore there is at least one path of length 2.
Corollary 2
if (N-1)^2 < E < N(N-1), the number of rounds is 2.
Theorem 3
If E = N(N-1), the number of rounds is 1
Proof
Trivial. Complete graph.
Now, you are asking about more than 95% of the node pairs.
Of course we can build some (N-1)^2 < E < N(N-1) graphs, where >= 95% of ordered-node-pairs can communicate in 1 round, but the other ordered-node-pairs communicate in 2 rounds.
This is trivial if you consider a complete directed graph of 6 nodes where only one edge is removed. (6*5-1) / (6*5) = 96.66% of the ordered-node-pairs can communicate in one round.
Why do you ask specifically about 95%? Is it important to derive calculations for exactly this number? Let us know. I don't think that you can derive a simple accurate generic formula, especially when N and E are small. Maybe we can formulate something asymptotically (for very large N).

Finding probability of edges in a graph

I have a random graph G(n, p) with n = 5000 vertices and an edge probability of p = 0.004.
I wonder what would be the expected number of edges in the graph but I have not much knowledge in probability-theory.
Can anyone help me?
Thank you so much!
EDIT:
If pE is the number of possible edges in the Graph, wouldn't I have to calculate 0.004 * pE to get the expected number of edges in the graph?
First, ask yourself the maximum number of possible edges in the graph. This is when every vertex is connected to every single other vertex (nC2 = n * (n-1)/2), assuming this is an undirected graph without self-loops).
If each possible edge has a likelihood of 0.004, and the # of possible edges is n(n-1)/2, then the expected number of edges will be 0.004*(n(n-1)/2).
The number of expected vertices depend on the number of nodes and the edge probability as in E = p(n(n-1)/2).
The total number of possible edges in your graph is n(n-1) if any i is allowed to be linked to any j as both i->j and j->i. I am your friend, you are mine. If the graph is undirected (and an edge only means that we are friends) the total number of edges drop by half: n(n-1)/2 since i->j and j->i are the same.
The multiplication with p gives the expected number of edges, since every possible edge has become real or not depending on the probability. p=1 gives n(n-1)/2 edges since every possible edge actually happened. For graphs with p<1, the actual edge count might (obviously) differ from time to time if you were to actually generate a random graph using the p and n of your choice. Expected edge count will however be the most common observed edge count if you were to generate an infinite number of random graphs. NetLogo is a very pedagogical tool if you want to generate random graphs and get a feel for how network measurements arise from random graphs of different structures.

What is the maximum number of edges in a directed graph with n nodes? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
What is the maximum number of edges in a directed graph with n nodes? Is there any upper bound?
If you have N nodes, there are N - 1 directed edges than can lead from it (going to every other node). Therefore, the maximum number of edges is N * (N - 1).
Directed graph:
Question: What's the maximum number of edges in a directed graph with n vertices?
Assume there are no self-loops.
Assume there there is at most one edge from a given start vertex to a given end vertex.
Each edge is specified by its start vertex and end vertex. There are n
choices for the start vertex. Since there are no self-loops, there are
n-1 choices for the end vertex. Multiplying these together counts all
possible choices.
Answer: n(n−1)
Undirected graph
Question: What's the maximum number of edges in an undirected graph with n vertices?
Assume there are no self-loops.
Assume there there is at most one edge from a given start vertex to a given end vertex.
In an undirected graph, each edge is specified by its two endpoints
and order doesn't matter. The number of edges is therefore the number
of subsets of size 2 chosen from the set of vertices. Since the set of
vertices has size n, the number of such subsets is given by the
binomial coefficient C(n,2) (also known as "n choose 2"). Using the
formula for binomial coefficients, C(n,2) = n(n-1)/2.
Answer: (n*(n-1))/2
In an undirected graph (excluding multigraphs), the answer is n*(n-1)/2. In a directed graph an edge may occur in both directions between two nodes, then the answer is n*(n-1).
In addition to the intuitive explanation Chris Smith has provided, we can consider why this is the case from a different perspective: considering undirected graphs.
To see why in a DIRECTED graph the answer is n*(n-1), consider an undirected graph (which simply means that if there is a link between two nodes (A and B) then you can go in both ways: from A to B and from B to A). The maximum number of edges in an undirected graph is n(n-1)/2 and obviously in a directed graph there are twice as many.
Good, you might ask, but why are there a maximum of n(n-1)/2 edges in an undirected graph?
For that, Consider n points (nodes) and ask how many edges can one make from the first point. Obviously, n-1 edges. Now how many edges can one draw from the second point, given that you connected the first point? Since the first and the second point are already connected, there are n-2 edges that can be done. And so on. So the sum of all edges is:
Sum = (n-1)+(n-2)+(n-3)+...+3+2+1
Since there are (n-1) terms in the Sum, and the average of Sum in such a series is ((n-1)+0)/2 {(last + first)/2}, Sum = n(n-1)/2
If the graph is not a multi graph then it is clearly n * (n - 1), as each node can at most have edges to every other node. If this is a multigraph, then there is no max limit.
Putting it another way:
A complete graph is an undirected graph where each distinct pair of vertices has an unique edge connecting them. This is intuitive in the sense that, you are basically choosing 2 vertices from a collection of n vertices.
nC2 = n!/(n-2)!*2! = n(n-1)/2
This is the maximum number of edges an undirected graph can have. Now, for directed graph, each edge converts into two directed edges. So just multiply the previous result with two. That gives you the result: n(n-1)
In a directed graph having N vertices, each vertex can connect to N-1 other vertices in the graph(Assuming, no self loop). Hence, the total number of edges can be are N(N-1).
In the graph with self loop
max edges= n*n
such as we have 4 nodes(vertex)
4 nodes = 16 edges= 4*4
There can be as many as n(n-1)/2 edges in the graph if not multi-edge is allowed.
And this is achievable if we label the vertices 1,2,...,n and there's an edge from i to j iff i>j.
See here.
The correct answer is n*(n-1)/2. Each edge has been counted twice, hence the division by 2. A complete graph has the maximum number of edges, which is given by n choose 2 = n*(n-1)/2.
Can also be thought of as the number of ways of choosing pairs of nodes n choose 2 = n(n-1)/2. True if only any pair can have only one edge. Multiply by 2 otherwise
Undirected is N^2. Simple - every node has N options of edges (himself included), total of N nodes thus N*N

Resources