0

I am trying to run a Project in Eclipse as a Java application. The error is in one of its class.

public static List<Graph<Integer, String>> graphList = new ArrayList<>(); // Java 7 syntax
public static Graph<Integer, String>[] graph = new Graph[100];

    // populate 'graph'

public static Graph<Integer, String> g=new SparseMultigraph<Integer,String>();

and the error is this : Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: The type Graph is not generic; it cannot be parameterized with arguments

I tried everything from configuring path to updating JRE system library. I am using java.util.List too. Can anyone please throw some light on how to solve this problem . Thanks

Codebender
  • 14,221
  • 7
  • 48
  • 85
Samar Khan
  • 41
  • 2
  • Want to clear up the formatting of that source a little? What are the asterisks for, for example? –  Jun 19 '15 at 08:31
  • 2
    Check that you are importing the correct Graph class. – greg-449 Jun 19 '15 at 08:44
  • I am importing these classes from jung library : import edu.uci.ics.jung.graph.Graph; import edu.uci.ics.jung.graph.SparseMultigraph; – Samar Khan Jun 19 '15 at 08:52
  • 1
    can it be you're working with [JUNG 1.7.6](http://javadox.com/jung/jung/1.7.6/doc/edu/uci/ics/jung/graph/Graph.html)? The `Graph` class there does not seem very generic. You would need [JUNG 2.0](http://www.java2s.com/Code/Jar/j/Downloadjunggraphimpl201sourcesjar.htm) to be able to use the generic `Graph`. – Mr Tsjolder from codidact Jun 19 '15 at 09:01
  • @MrTsjolder is most likely correct, i.e., you're using a version of JUNG that is pre-2.0. – Joshua O'Madadhain Jun 23 '15 at 18:19

1 Answers1

0

The Graph interface needs Vertex and Edge types specified < V,E >.

public static Graph g=new SparseMultigraph();

Change the above code to something like this:

Graph<Integer, String> g = new SparseMultigraph<Integer, String>();

Refer link below for an example: http://www.grotto-networking.com/JUNG/BasicGraphCreation.java

If you still experience a problem, refer thread below: The type Collection is not generic; it cannot be parameterized with arguments <? extends E>

Community
  • 1
  • 1
Chaitanya P
  • 120
  • 7