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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:42:10+00:00 2026-06-03T19:42:10+00:00

I have a problem about UndirectedGraph usage. My code : UndirectedGraph<String, DefaultEdge> graph =

  • 0

I have a problem about UndirectedGraph usage. My code :

UndirectedGraph<String, DefaultEdge> graph =
            new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);

 String v1 = "v1";
 String v2 = "v2";
 String v3 = "v3";
 String v4 = "v4";

 graph.addVertex(v1);
 graph.addVertex(v2);
 graph.addVertex(v3);
 graph.addVertex(v4);

 graph.addEdge(v1, v2);
 graph.addEdge(v2, v3);
 graph.addEdge(v3, v4);
 graph.addEdge(v4, v1);

Each vertex was added to graph successfully. Hovewer, addEdge method didn’t work properly. When I debug this code, first addEdge line threw class not found exception.

I hope, you will help me. Thanks.

  • 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-03T19:42:11+00:00Added an answer on June 3, 2026 at 7:42 pm

    With jgrapht-0.8.3, the following works as expected:

    import org.jgrapht.UndirectedGraph;
    import org.jgrapht.graph.DefaultEdge;
    import org.jgrapht.graph.SimpleGraph;
    
    public class GraphTest {
    
      public static void main(String[] args) {
        UndirectedGraph<String, DefaultEdge> graph =
          new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
    
        String v1 = "v1";
        String v2 = "v2";
        String v3 = "v3";
        String v4 = "v4";
    
        graph.addVertex(v1);
        graph.addVertex(v2);
        graph.addVertex(v3);
        graph.addVertex(v4);
    
        graph.addEdge(v1, v2);
        graph.addEdge(v2, v3);
        graph.addEdge(v3, v4);
        graph.addEdge(v4, v1);
        
        if( graph.getEdge(v1, v2) != null) { System.out.println("SUCCESS"); }
        if (graph.getEdge(v2,v4) == null)  { System.out.println("SUCCESS"); }
      }
    }
    

    I get

    SUCCESS

    SUCCESS

    Can you clarify what problem you’re having?

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

Sidebar

Related Questions

i have a problem. i want to get info about my string have other
I have a problem about malloc(). It is weird. My code is in the
I have a problem about counting the length of a string. I always get
I have a problem about SQL. How can i split a string with a
I have a problem about designing. I should use class or struct in this
I'm new to rails and I have this small problem about helpers and controllers.
I'm new here,and i have some problem about FOAF. I use jena create a
I have problem about IF ELSE in Command Batch script... In Notepad: Code: :CHECKACCOUNT
I have a problem about div position relative alignment. I want the second div
I am using MFC CFile Seek function. I have a problem about Seek out

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.