Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

I have a graph with Edge E and Vertex V, I can find the spanning tree using Kruskal algorithm, now I want to find all the cycle bases that are created by utilitizing that spanning tree and the edges that are not on the tree, any algorithm that allows me to do that, besides brute force search?

I can, of course, starts from one vertex of the non-spanning tree edge, gets all the edges, explore all of them, retracts if I find dead end, until I come back to the other vertex of the edge. But this is a bit, err... brutal. Any other ideas?

share|improve this question
    
You don't need Kruskal, Ngu! You can find a spanning tree trivially -- it doesn't have to be minimum. Newcomers, see mathoverflow.net/questions/1443/… for Ngu's initial question. –  TonyK Oct 22 '09 at 18:15
    
Sure, I can find spanning tree-- with or without Kruskal. But my question is how to form the cycle base without resorting to something what I call 'brute force'. –  Graviton Oct 23 '09 at 1:34
add comment

2 Answers 2

up vote 3 down vote accepted

I think you're likely to get better answers if you post this question on Stack Overflow rather than here.

But anyways, if your graph doesn't have weights on edges, you don't need Kruskal's algorithm to find a spanning tree; you can just use DFS. As you compute the tree, store for each vertex its parent and the distance to the root. Then when you encounter a non-tree edge, you can find the nearest common ancestor of its two endpoints efficiently.

share|improve this answer
    
Even with weights, you can use DFS to find a spanning tree. It might not have any nice properties, though. –  Michael Lugo Oct 22 '09 at 18:03
    
>if your graph doesn't have weights on edges I agree, but But my question is how to form the cycle base without resorting to something what I call 'brute force'. –  Graviton Oct 23 '09 at 1:34
add comment

Although this thread is long-dead, there is a very simple way to do this with linear algebra, so I will post an answer.

You are interested in a basis of the cycle space of $G$. Orient $G$ in any way. Let $\partial(G)$ be the edge-vertex incidence matrix of $G$. A basis of the cycle space is given by a basis for $\ker \partial(G)$. To get the answer to your question note that if you take any spanning tree $T$ and you consider the edges of $E-T$, there will be a unique element of the cycle space that is $1$ on a given edge of $E-T$ and $0$ on the others. Finding such an element for each edge of $E-T$ will yield a new basis for $\ker \partial(G)$.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.