Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 411395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:58:58+00:00 2026-05-12T17:58:58+00:00

I have an undirected graph with Vertex V and Edge E . I am

  • 0

I have an undirected graph with Vertex V and Edge E. I am looking for an algorithm to identify all the cycle bases in that graph.

I think Tarjans algorithm is a good start. But the reference I have is about finding all of the cycles, not cycle base ( which, by definition is the cycle that cannot be constructed by union of other cycles).

For example, take a look at the below graph:

So, an algorithm would be helpful. If there is an existing implementation (preferably in C#), it’s even better!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:58:58+00:00Added an answer on May 12, 2026 at 5:58 pm

    From what I can tell, not only is Brian’s hunch spot on, but an even stronger proposition holds: each edge that’s not in the minimum spanning tree adds exactly one new “base cycle”.

    To see this, let’s see what happens when you add an edge E that’s not in the MST. Let’s do the favorite math way to complicate things and add some notation 😉 Call the original graph G, the graph before adding E G’, and the graph after adding E G”. So we need to find out how does the “base cycle count” change from G’ to G”.

    Adding E must close at least one cycle (otherwise E would be in the MST of G in the first place). So obviously it must add at least one “base cycle” to the already existing ones in G’. But does it add more than one?

    It can’t add more than two, since no edge can be a member of more than two base cycles. But if E is a member of two base cycles, then the “union” of these two base cycles must’ve been a base cycle in G’, so again we get that the change in the number of cycles is still one.

    Ergo, for each edge not in MST you get a new base cycle. So the “count” part is simple. Finding all the edges for each base cycle is a little trickier, but following the reasoning above, I think this could do it (in pseudo-Python):

    for v in vertices[G]:
        cycles[v] = []
    
    for e in (edges[G] \ mst[G]):
        cycle_to_split = intersect(cycles[e.node1], cycles[e.node2])
        if cycle_to_split == None:
            # we're adding a completely new cycle
            path = find_path(e.node1, e.node2, mst[G])
            for vertex on path:
                cycles[vertex].append(path + [e]) 
            cycles
        else:
            # we're splitting an existing base cycle
            cycle1, cycle2 = split(cycle_to_split, e)
            for vertex on cycle_to_split:
                cycles[vertex].remove(cycle_to_split)
                if vertex on cycle1:
                    cycles[vertex].append(cycle1)
                if vertex on cycle2:
                    cycles[vertex].append(cycle2)
    
    base_cycles = set(cycles)
    

    Edit: the code should find all the base cycles in a graph (the base_cycles set at the bottom). The assumptions are that you know how to:

    • find the minimum spanning tree of a graph (mst[G])
    • find the difference between two lists (edges \ mst[G])
    • find an intersection of two lists
    • find the path between two vertices on a MST
    • split a cycle into two by adding an extra edge to it (the split function)

    And it mainly follows the discussion above. For each edge not in the MST, you have two cases: either it brings a completely new base cycle, or it splits an existing one in two. To track which of the two is the case, we track all the base cycles that a vertex is a part of (using the cycles dictionary).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that represents undirected edges in a graph. Every edge has
I have got an undirected weighted connected graph. If I select one vertex I
A similar question is posted here . I have an undirected graph with Vertex
I have an undirected unweighted graph G = (V, E) and a randomly chosen
Given a weighted graph (directed or undirected) I need to find the cycle of
I have an unweighted, connected graph. I want to find a connected subgraph that
I'm trying to write code that will traverse an undirected, unweighted graph. Essentially, the
I have a graph with multiple edge weightings stored as namespace boost { enum
I need to store a large and dynamic undirected graph in google appengine, what's
From this Wikipedia article: http://en.wikipedia.org/wiki/Hamiltonian_path_problem A randomized algorithm for Hamiltonian path that is fast

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.