[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 583: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 639: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
Gephi forums •How to Have A New Graph From Scratch
Page 1 of 1

How to Have A New Graph From Scratch

Posted: 26 Apr 2013 00:43
by thecoolboy
When I run the code below, it gives the error: A java.lang.IllegalArgumentException exception has occurred.

GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
GraphView newView = graphModel.newView();
Graph[] newGraph = new Graph[0];
newGraph = new Graph[]{graphModel.getHierarchicalUndirectedGraph(newView)};
newGraph[0].clear();
newGraph[0].clearEdges();

Node n;
Node n2;
n = graphModel.factory().newNode();
newGraph[0].addNode(n);
n2 = graphModel.factory().newNode();
newGraph[0].addNode(n2);
newEdge = graphModel.factory().newEdge(n, n2);
newGraph[0].addEdge(newEdge);


It should work according to here: http://gephi.org/docs/api/org/gephi/gra ... Model.html

Can anybody tell me please what I am doing wrong?

Re: How to Have A New Graph From Scratch

Posted: 28 Apr 2013 23:14
by eduramiba
Hi,
I think this is a problem with views, I can't see what's wrong.

Anyway, you can use the main view, don't need to create a new one.
This works:

Code: Select all

ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
pc.newProject();

GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
Graph graph = graphModel.getHierarchicalUndirectedGraph();

Node n;
Node n2;
n = graphModel.factory().newNode();
n2 = graphModel.factory().newNode();
Edge newEdge = graphModel.factory().newEdge(n, n2);

graph.addNode(n);
graph.addNode(n2);
graph.addEdge(newEdge);
Eduardo

Re: How to Have A New Graph From Scratch

Posted: 03 May 2013 16:24
by thecoolboy
Ok, will try to do that. Thanks.

Re: How to Have A New Graph From Scratch

Posted: 31 Oct 2014 13:36
by Sxandy
Let's call Graph A the graph with a max edge attribute (call this F) of 150 while Graph B has a max F of 250. (Also wanted to clarify I'm using an edge attribute and not the weight, which I'm not sure how is calculated)

1. Specify a two point color scale for edges for Graph A using attribute F, ends up applying to the range 1-150.
2. Run a preview, there is an edge in the graph that uses the "max" color of the scale.
3. On Graph B, added an Attribute -> Range filter, limiting range between 1-150, and then applied the same color scale.


__________________________
Scarlett