I'm developing a c++ program which calculate and draw all possible connected planar graphs with given E number edge. Like this :
My first thought was to find all possible solutions for the N edge by adding one edge to after finding the answer to (n-1) by doing recursion.
As you can see in the picture, the solution of the problem n = 4 is basically an improved version of the solution n = 3 with one edge more.
But it did not feel like a very effective solution. I could not find this problem in a particular algorithm.
is there any other way of finding and drawing all possible connected planar graphs with E edge?
is there any other way of finding and drawing all possible connected planar graphs with E edge?
Start with the complete graph K(E+1) - this will have (E+1) vertices and E(E+1)/2 edges. Enumerate the edges 1 .. E(E+1)/2.
For each permutation of E values from the set <1 .. E(E+1)/2>
Keep those E edges and delete the rest
Delete any unconnected vertices
If the graph is connected, planar and is not isomorphic to a previous graph then
It is a new unique graph with E edges.
You can probably perform significant optimisations by considering the symmetry of the complete graph and eliminating permutations that have a combination of rotational and/or reflectional symmetry with a previous permutation.
Related
Could someone explain in pretty simple words why the normalization of many network analysis indicies (graph theory) is n(n - 1), where n – the graph size? Why do we need to take into account (n - 1)?
Most network measures that focus on counting edges (e.g. clustering coefficient) are normalized by the total number of possible edges. Since every edge connects a pair of vertices, we need to know how many possible pairs of vertices we can make. There are n possible vertices we could choose as the source of our edge, and therefore there are n-1 possible vertices that could be the target of our edge (assuming no self-loops, and if undirected divide by 2 bc source and target are exchangeable). Hence, you frequently encounter $n(n-1)$ or $\binomal{n}{2}$.
Is it possible to find all possible directed graphs given a pair of vertices and the information that an edge exists between them? For example if we know the vertices with edge pairs like
1 2
2 3
1 3
The possible directed graphs will be:
1→2, 2→3, 1→3
1→2, 2→3, 3→1
1→2, 3→2, 1→3
1→2, 3→2, 3→1
2→1, 2→3, 1→3
2→1, 2→3, 3→1
2→1, 3→2, 1→3
2→1, 3→2, 3→1
What data-structure to be used here to work with? What can be the working logic?
I was thinking of using adjacency matrix data structure and compute all possible adjacency matrix. Each adjacency matrix will represent a graph. We can use the graph as and when needed for tasks like checking whether cycle is present or not etc.
Apologies that this is more of a discussion than a programming question, but any help will be appreciated
You could maintain one undirected graph data structure G and work with the knowledge that the existence of an edge (u,v) means that there is only one directed edge in a particular instance of digraph possibility D.
If you want to maintain all possible digraphs separately, you would need 2^m many of them, where m is the number of edges. If the vertices and edges are always the same and only the direction is the invariant, then you could maintain 2^m bit-strings, each of length m. Each bit has a 0 or 1 depending on whether the edge (u,v) it corresponds to is u-->v or v<--u. Use the bit string to give direction to the undirected graph suggested above. You just need to generate all 2^m bit strings. Not very efficient... but you can't do better if you need to work with all possibilities.
You could use the bit string to construct a digraph. But, it would be more memory efficient at least to maintain only one bit-string per 'graph' rather than repeating the entire graph data structure with only directional changes. Record bit strings in a hash table: use each edge as a key and then bit value 0/1 depending on direction. Any graph traversal of one of the many possible digraphs D works on undirected G. Then in constant time you can check for incident (undirected) edges of a vertex, which are outgoing/incoming in D. So traversals can occur just as quickly by maintaining only 1 graph object and 1 bit hash table of size 2^m (rather than 2^m graph objects).
My problem is a generalization of a task solved by [Blossom algorithm] by Edmonds. The original task is the following: given a complete graph with weighted undirected edges, find a set of edges such that
1) every vertex of the graph is adjacent to only one edge from this set (i.e. vertices are grouped into pairs)
2) sum over weights of edges in this set is minimal.
Now, I would like to modify the first goal into
1') vertices are grouped into sets of 3 vertices (or in general, d vertices), and leave condition 2) unchanged.
My questions:
Do you know if this 'generalised' problem has a name?
Do you know about an algorithm solving it in number of steps being polynomial of number of vertices (like Blossom algorithm for an original problem)? I don't see a straightforward generalisation of Blossom algorithm, as it is based on looking for augmenting paths on a graph compressed to a bipartite graph (and uses here Hungarian algorithm). But augmenting paths do not seem to point to groups of vertices different than pairs.
Best regards,
Paweł
Given two points (vertices), say i and j represented by small circles. How can I draw an arc (arrow) connecting those two vertices in Javafx 8? Surprisingly, very little information exists on drawing arcs in javafx8.
Given two points,(vertices), say i and j and a number of arcs between the two vertices. For each arc a direction is given. So for example, I can have 2 arcs from i to j, and 1 arc from j to i. How can I draw these arcs in javafx 8 such that they don't overlap each other. I was thinking on drawing each arc as half of an oval.
Normally I would provide sample code, but here I really have no clue how to draw an arc in between two points in Javafx?
Here is an example of something I would like to draw:
In my application I know the exact coordinates for the vertices a,b,c,d. I just need to know how to draw the arcs (I would favor a faster, simple solution over a pretty solution).
In an undirected, unweighted graph, and I'm trying to print (store in file) all possible connecting paths between given 2 vertices on the graph, not including cycles.
when you consider a complete graph this problem is a NP-complete. because there are "(V-2)!" different paths between 2 vertices.
However,seems it is possible to do it with one of graph traversal (DFS-BFS) algorithm with time complexity of O(|V|+|E|) which is pretty polynomial.
I got confuse about solving a NP-Complete problem in polynomial time?
any idea about what is missing here ?
If you want all possible paths, and the graph has V vertices, and E edges, then the number of paths will be dependent upon the number of connects. Consider a fully connected graph, where every point connects to every other point. Then there are (v-2)! possible paths, right? Well (v-2)! > V+E (much greater).