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

  • Home
  • SEARCH
  • 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 8750907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:56:54+00:00 2026-06-13T12:56:54+00:00

When I have a graph with weights and a random generator how can I

  • 0

When I have a graph with weights and a random generator how can I select some edges more desirable? I have a constraint of x weight and I need a formula that includes x weight and let me choose the next edge and so on. For example I have 4 edges with weight 5,10,15,20. How can I make the edge with weight 5 more desirable with a random generator but also when I have already choose edge 5 I need not choose edge with weight 20 because it exceeds my constraint.

  • 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-13T12:56:55+00:00Added an answer on June 13, 2026 at 12:56 pm

    By defining the probability that one particular edge be selected as:

      P(select_this_edge) = (x - Weight_of_this_edge) / x
    

    This will make edges with a low weight more likely to be selected, and edges with a weight bigger than the “constraint”, x, impossible to select.

    Assuming that the RNG (random number generator) produces values between 0 and 1, the process to decide if a given edge should be selected is to draw a random number and see if it is less or equal to the probability as computed in the formula.

    Depending on you specific needs, you could alter the formula slightly, for example by introducing a small factor that would prevent an edge with weight 0 to be systematically selected (by introducing a residual chance that it wouldn’t be selected), and conversely to prevent edges with a higher than “constraint” x edge value of never being selected.

    Now… the above discusses the way of assigning probability to decide if a given edge should be selected. This is quite sufficient if indeed the program logic has a way of picking individual edges and simply asks itself the simple question “Should this particular edge be selected?”. However the program logic may have come up with a list of edges (which could be the complete collection of edges) and want to answer a more complicated question: “Of these n edges which one should I select ?”.
    I was about to explain how to go about this 2nd type of problem, but in reading -between the lines- of the various comments, I think I understand better the problem at hand…


    Edit (after various clarifications in comments)
    As suspected, the underlying problem is that of an optimization problem rather than one of probability (although in this instance, probabilities are used to direct the search into the solution space in a stochastic fashion).
    Specifically, the problem is one of the many variations on the Capacitated Vehicle Routing Problem

    Without knowing details of what specific parameters (or combination thereof) we are trying to optimize, I can only speak in broad terms, trying to answer one of the questions of the OP:
    Is is ok to combine the probability associated with Weight with the probability associated with distance ?

    In a nutshell, yes it is. A plain multiplication may do the trick, although I would like to suggest a formula akin to the following:

    P(e) = Kw * Pw(e) + Kd Pd(e) + some_random_term
    Where 
       P(e) is the probability of picking edge e, "all things considered"
       Kw and Kd are constant parameters which can be used to tweak the algorithm
       Pw(e) is the probability of picking egde e, with consideration to the Weight
       Pd(e) is the probability of picking egde e, with consideration to the Distance
       some_random_term is used to soften the algorithm in its tendency to favor too
          much high probability edges resulting in allowing the search process to get
          stuck in local minima.
          Rather than a added term, this can also be performed by a simple function
          which prevents the probability to be less than say 0.05 or more than say
          0.95.  A fancier sigmoid function may also do the trick.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we have a graph with bidirectional edges, no weights. How can I store
If we have an (arbitrary) connected undirected graph G, whose edges have distinct weights,
I have a graph representing users and some articles they wrote. I need to
Dijkstra's Algorithm fails when in a graph we have edges with negative weights. However,
I have a graph in Prolog represented by the edges & weights: connected(a,b,2). connected(b,e,1).
Suppose I have a graph where the minimum edge weight is −100. Can I
So, I have a graph of vertices which have certain weights and edges. I'm
Here is an excise: In certain graph problems, vertices have can have weights instead
I have oriented graph. Graph can be strongly connected. Every vertex can have a
What algorithm I can use for problem like this: Have a graph positive weighted,

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.