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 8156445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:57:20+00:00 2026-06-06T16:57:20+00:00

How should I proceed on doing this? This IS a homework, and I’m having

  • 0

How should I proceed on doing this?
This IS a homework, and I’m having a huge problem with it.
Now, the issue is that I must not use libs.

I have a graph like:

{'A': {'C': 2, 'B': 10}, 'C': {'B': 7, 'D': 2}, 'B': {}, 'D': {'A': 5, 'B': 4}}

using dictionaries, taken from a file.

I am using the algorithm at http://www.python.org/doc/essays/graphs/ to find all the paths, so there is no problem there.

But now that I have all the paths from one point to another, I need to sum the weights and get the complete cost on it.

If you could help me, and direct me on some good ways to approach it, I would appreciate it.

  • 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-06-06T16:57:21+00:00Added an answer on June 6, 2026 at 4:57 pm
    gr = {'A': {'C': 2, 'B': 10},
          'C': {'B': 7, 'D': 2},
          'B': {'E': 2},
          'D': {'A': 5, 'B': 4, 'E': 3}
          'E': {}}
    
    def paths(gr, frm, to, path_len=0, visited=None):
    
        if frm == to:
            return [[to, path_len]]
    
        visited = visited or []
        result = []
        for point, length in gr[frm].iteritems():
            if point in visited:
                continue
            visited.append(point)
            for sub_path in paths(gr, point, to, path_len + length, visited[:]):
                result.append([frm] + sub_path)
    
        return result
    
    >>> print paths(gr, 'A', 'E')
    [['A', 'C', 'B', 'E', 11], ['A', 'C', 'D', 'E', 7], ['A', 'B', 'E', 12]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know that how one should proceed in building animated splash screen.
Why does Convert.ToBoolean(1) throw a System.FormatException ? How should I proceed with this conversion?
Should timestamps always use UTC (as in 2012-06-14T10:32:11+00:00 ) and not local time (as
Pretend you have a button on an iOS GUI. Pressing this button should now
First of all, this is the first time that I use Hibernate so my
So I am using FCKeditor and the problem I am having is that when
I was wondering how should I proceed to debug while working with frameworks. Like
I am doing an automatic train protection on Ada with SPARK approach. This is
The basic problem is that upon trying to uninstall the default SQL 2005 express
I've done a client-server voice chat (like ventrilo) in C# and am now doing

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.