How to Have A New Graph From Scratch

Visual manipulations and refinements
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
thecoolboy
Posts:51
Joined:12 Oct 2011 23:01
Location:Arkansas,USA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
How to Have A New Graph From Scratch

Post by thecoolboy » 26 Apr 2013 00:43

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?

User avatar
eduramiba
Gephi Code Manager
Posts:1064
Joined:22 Mar 2010 15:30
Location:Madrid, Spain
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: How to Have A New Graph From Scratch

Post by eduramiba » 28 Apr 2013 23:14

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

thecoolboy
Posts:51
Joined:12 Oct 2011 23:01
Location:Arkansas,USA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: How to Have A New Graph From Scratch

Post by thecoolboy » 03 May 2013 16:24

Ok, will try to do that. Thanks.

Sxandy
Posts:1
Joined:31 Oct 2014 13:30
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: How to Have A New Graph From Scratch

Post by Sxandy » 31 Oct 2014 13:36

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

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable