Graph traversal with a minimum number of "steps" (steps based on edge parameters) - graph

There is a bidirectional graph. The graph edges have parameters (let it be a color). A step is a transition from one vertex to another. If at a certain moment the already visited vertices have unvisited edges with the same parameters, then in 1 step it is possible to go through all the edges with the same parameters. Edges can have multiple parameters.
I need to find a traversal algorithm to visit all the vertices with a minimum number of "steps".
Example graph (1 and 2 are starting (visited) vertices):
graph example
Expected result: 6, 3 and 5, 4 and 7 (3 steps)
I want to iterate over all graph traversal options to find the best. But maybe there is any better algorithm for this task? If not, what is the best way to find all traversal options?

Related

Implementing BFS on same level vertexes of a graph data structure

I'm trying to understand graphs in data structures and got struck here in understanding. can anyone help in understanding this approach. Graphs allow multiple vertexes to connect to any arbitrary vertex without any constraints. while inserting edges, it is possible the vertex to be connected may be on the same level or at any below levels.
In the above figure, BFS through graphs gives 5,6,7 in one and 5,7,6 in another. There is no constraint to get the same level vertexes on graph. How is this identified?
Please let me know as none of the resources point that differenece. Both 6,7 are unvisited from 5,if one refers to 7 and adds to queue(image-1). BFS will be violated.
EDIT:
In the above BFS Example image we have 5 vertexes and if we start from 5 we can either traverse to 6,7 as adjacent nodes. if we are trying to implement BFS here then we can either add 6 or 7 to queue but 7 is the valid one as it is at the same level. How is this identified?
The two drawings you posted show identical graphs: the same three vertices are connected with the same three edges. Graphs don't have levels. They don't keep track of any type of edge ordering, nor the horizontal or vertical layout of the vertices when the graph is drawn.
A BFS starting from vertex 5 could visit either 6 or 7 next. Either order is a valid BFS traversal.

Explanation of network indices normalization

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}$.

algorithm for 'generalized' matching in complete graphs

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ł

Sequence of number of vertices in a graph

I want to generate a sequence of the number of vertices in all graphs which each edge has the same number of leaving edges. I dont have to generate the whole sequence. Let's say the first 50 if exists.
I want:
Input: the number of edges leaving each vertex
Output: a sequence of the number of vertices
So far, I have looked at complete graphs. Complete graphs with n vertices always have n-1 edges leaving each vertex. But there are other kinds of graphs that have this property. For example, some polyhedrons, such as snub dodecahedron and truncated icosidodecahedron have this property.
How should I approach my problem?
I think you mean regular graphs:
http://en.wikipedia.org/wiki/Regular_graph
http://mathworld.wolfram.com/RegularGraph.html
I made a regular graph generator which isn't flawless by the way:
once you generate the nodes, say from 1 to n. You want regularity r.
For node 1, make connections to the following nodes until you reach degree r for node 1.
For node 2 you already have degree 1 (because of node 1), you connect again to further nodes until you reach degree r for node 2 too. And this way till the last node.
The flaw is that you can't define an r-regular graph for any number of nodes. The algorithm mentioned doesn't detect that, so some errors may occur. Also, this isn't a random r-regular graph generator, but instead give one possible solution.
I'm not much of an explainer, so please ask if the description lacks somewhere.

How can you describe this kind of graph?

I know for sure that this is a simple directed graph. But I cannot say that this is a ring graph/network, because node 3 has a degree of 4. But as I imagine this, you cannot go to node 7 from node 3 if the preceding node is node 2, and you cannot go to node 4 from node 3 if the preceding node is node 6. That means the only way to traverse this graph is to start from one node and then go to the adjacent node that has a number greater than the current node (except for node 7 to node 1). What kind of graph is this? Thanks in advance!
http://img231.imageshack.us/img231/5492/graphl.jpg
Yes, it is a simple directed graph. It is also an Eulerian graph with exactly one Eulerian circuit. That's probably its most interesting property.
You could redraw the graph as a standard Eulerian Graph without the addition rules by dividing node 3 into two nodes, node 3 and node 6A, where 2-3-4 and 6-6A-7 are the only valid paths through the two nodes. At this point the graph would look like a figure eight. The nodes could then be rearranged in a circle while maintaining the topology.

Resources