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

The Archive Base Latest Questions

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

I have a graph with 4 nodes which are connected with other nodes. Each

  • 0

I have a graph with 4 nodes which are connected with other nodes. Each connection has weight. For example:

A -> 5 -> B

A -> 3 -> C

B -> 4 -> C

B -> 3 -> D

Each node has backward connection correspondingly. But I have a problem with realization of such backward connection. Here is algorithm (in words) of what I have now:

  1. Create nodes (A, B, C, D)
  2. Connect node A to node B
  3. Set connection weight
  4. Repeat 2,3 for other nodes.

Following this algorithm I have to make backward connections (node B to node A) separately. And if I have 100 nodes or more, it’ll be a trial for my attention.

How to make these backward connections during connection creation?

Here is a Node class:

public class Node {
    private String name;
    private Map<Node, Integer> connections;

    public Node(String name) {
        this.name = name;
        connections = new HashMap<Node, Integer>();
    }

    public void connect(Node node, int weight) {
        connections.put(node, weight);
        //It is expected to make backward connection here
    }
}
  • 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-13T19:56:20+00:00Added an answer on June 13, 2026 at 7:56 pm

    Like this:

    public void connect(Node node, int weight) {
        connections.put(node, weight);
        node.connections.put(this, weight);
    }
    

    Since Node is used as the key in the connections map, don’t forget to override its equals and hashCode methods.

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

Sidebar

Related Questions

I have a graph which is essentially an ArrayList of Nodes, each of which
I have several nodes (undirected graph, bidirecional) ... Each two nodes have a distance...
I have a d3 force-directed graph that contains a group of nodes: var node
I have about 70k nodes, and 250k edges, and the graph isn't necessarily connected.
I have a directed-graph, each node is a complex data type. Does anyone know
I have an app that displays the nodes of a connected graph. When the
I have a force-directed graph where on node mouseover the elements which are not
In a system I Have a list of nodes which are connected like in
I have a big csv file which lists connections between nodes in a graph.
I have a large dataset of philosophic arguments, each of which connect to other

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.