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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:43:48+00:00 2026-05-25T19:43:48+00:00

Map<K,V<List<K>> graph = new HashMap<K,V<List<K>>(); Are there any major obstacles to using this to

  • 0
Map<K,V<List<K>> graph = new HashMap<K,V<List<K>>();

Are there any major obstacles to using this to represent a directed graph that can be cyclical?

EDIT:

This was more confusing than it probably should have been. This is a conversation graph for an RPG, and here is what I have so far. I was trying to determine if I could refactor this into a simpler form:

Initialized for an NPC:

public interface ConversationGraphI {

    void init();

    Map<String, DialogueNodeI> getConversation();

    void setConversation(Map<String, DialogueNodeI> conversation);
}

A piece of dialogue, with response options:

public interface DialogueNodeI {

    String getText();

    void setText(String text);

    List<ResponseChoiceI> getResponseChoices();

    void setResponseChoices(List<ResponseChoiceI> responseChoices);
}

A response choice that can then loop back to another piece of dialogue in the map:

public interface ResponseChoiceI {

    String getResponseText();

    void setResponseText(String responseText);

    String getDialogueKey();

    void setDialogueKey(String dialogueKey);
}
  • 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-25T19:43:48+00:00Added an answer on May 25, 2026 at 7:43 pm

    I think the main issue with it is that you might not be able to store data about each edge easily. It depends on whether an object of type V will give you that. Still, I agree with Andrei LED’s comment that it’d be better to use an explicit Edge type:

    Map<K,Collection<Edge<K>>>
    

    If you don’t need to store edge metadata at all, then you could go even simpler:

    Map<K,Collection<K>>
    

    As an alternative to the all-in-one approach, I’ve seen graphs represented by two separate collections, one for nodes and one for edges. If N is a node, then something like this:

    Collection<N>  // nodes
    Collection<Edge<N>>  // edges between nodes
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using adjacency lists to represent a directed weighted graph and based on
Is there a way of automatically generating a HTML-Map compatible list of coordinates of
I have a list of Map.Entry<String,Integer> s that I am looping through, and for
I'm trying to map a List with an index column. This works fine, but
I am trying to understand Directed Graph implementation (without Boost library that is mentioned
I am working on a basic graph implementation(Adj List based) in C so that
I've built a graph using the following code: G = networkx.Graph() G.add_edges_from([list(e) for e
I've created a map system for a game that runs on the principle of
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
For an std::map<std::string, std::string> variables , I'd like to do this: BOOST_CHECK_EQUAL(variables[a], b); The

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.