Hi,
I've added something meaningful to the GEXF file under the <meta><description> tag.
How can I access this "description" attribute from code?
Thanks,
Warlax.
Accessing Graph meta data from code
- mbastian
- Gephi Architect
- Posts:728
- Joined:10 Dec 2009 10:11
- Location:San Francisco, CA [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: Accessing Graph meta data from code
These information are not used for the moment. I filled a bug about that issue. Thank you!
-
- Posts:18
- Joined:19 May 2010 20:45 [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: Accessing Graph meta data from code
mbastian,
Thanks for your quick and prompt response. As always, very much appreciated.
Any telling on when this bug will be dealt with?
Is there any other way you can think of that would allow an attribute about the graph/network to be accesible from code?
If there is no way, would you like me to help solve it and contribute the code? If so, could you give me a quick pointer on a comfortable entry-point in the code?
As a workaround, I could add the attribute to the nodes or edges and simply read that in the code - but that's not elegant. What about adding an entry to the <graph><attributes> with class="graph", will that be accessible somehow or will it just fail to parse the GEXF file?
Thanks man, much appreciated.
Warlax
Thanks for your quick and prompt response. As always, very much appreciated.
Any telling on when this bug will be dealt with?
Is there any other way you can think of that would allow an attribute about the graph/network to be accesible from code?
If there is no way, would you like me to help solve it and contribute the code? If so, could you give me a quick pointer on a comfortable entry-point in the code?
As a workaround, I could add the attribute to the nodes or edges and simply read that in the code - but that's not elegant. What about adding an entry to the <graph><attributes> with class="graph", will that be accessible somehow or will it just fail to parse the GEXF file?
Thanks man, much appreciated.
Warlax
- mbastian
- Gephi Architect
- Posts:728
- Joined:10 Dec 2009 10:11
- Location:San Francisco, CA [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: Accessing Graph meta data from code
The best way in my opinion is to store graph attributes into the workspace. In Gephi the workspace represent one graph, a new workspace is created for each file imported. The Workspace is defined in the Project API.Is there any other way you can think of that would allow an attribute about the graph/network to be accesible from code?
Yes, the aim is to allow set/get information about a workspace. The question is if there is always the same information (name, description, keywords, author, ...) or if we want to allow user-defined graph attributes. In both case we have to look at the "getLookup()" method in Workspace. A lookup in Gephi is a service (singleton ususally) container that can be queried with the name of the class. As explained in the Javadoc, it is therefore easy to store new class in a workspace and let other modules query it.If there is no way, would you like me to help solve it and contribute the code? If so, could you give me a quick pointer on a comfortable entry-point in the code?
If we want to support graph attributes, and be generic about it, the best way is to add a new table to the Attributes API. Columns for nodes and edges data are managed there. In the AttributeModel we could add a "getGraphTable()" method to allow to store any attribute with graph, i.e. workspace.
When this is done, we need to store values in Workspace. According to Attributes API, values are stored in AttributeRow. Our job is thus to create an instance of AttributeRow and put it in the Workspace's lookup.
That could be done in the Import API, where the files are read and their content appended to the workspace. There, more precisely in Processors, the graph attributes found during GEXF or other formats are appended to the workspace:
Code: Select all
AttributeRow row = workspace.getLookup().lookup(AttributeRow.class);
if(row==null) {
row = workspace.getLookup().lookup(AttributeModel.class).rowFactory().newGraphRow();
workspace.add(row);
}
-
- Posts:18
- Joined:19 May 2010 20:45 [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: Accessing Graph meta data from code
What about getting the path and/or file name of the graph file of the current workspace?
I used this:
But workspace doesn't seem to provide any 'getName()' or 'getFile()' methods.
I can see the 'getLookup' but I don't know what class to pass to it to get the project file name.
I used this:
Code: Select all
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = pc.getCurrentWorkspace();
I can see the 'getLookup' but I don't know what class to pass to it to get the project file name.
- mbastian
- Gephi Architect
- Posts:728
- Joined:10 Dec 2009 10:11
- Location:San Francisco, CA [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: Accessing Graph meta data from code
You can query WorkspaceInformation in the Lookup.
-
- Posts:18
- Joined:19 May 2010 20:45 [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: Accessing Graph meta data from code
Hi,
Sorry about the long turn around time for this thread.
I am using WorkspaceInformation to get the source file name for the current workspace:
However, source is just the file name.
Is there a way to get the file path to the file so I can find the file on the file system?
Thanks.
Sorry about the long turn around time for this thread.
I am using WorkspaceInformation to get the source file name for the current workspace:
Code: Select all
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
Workspace workspace = pc.getCurrentWorkspace();
WorkspaceInformation info =
workspace.getLookup().lookup(WorkspaceInformation.class);
String source = info.getSource();
Is there a way to get the file path to the file so I can find the file on the file system?
Thanks.
- mbastian
- Gephi Architect
- Posts:728
- Joined:10 Dec 2009 10:11
- Location:San Francisco, CA [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: Accessing Graph meta data from code
No, this information is not stored in the WorkspaceInformation.Is there a way to get the file path to the file so I can find the file on the file system?
However there is a workaround and you can get the path from the "MostRecentFilesAPI" module:
Code: Select all
List<String> list = Lookup.getDefault.lookup(MostRecentFiles.class).getMRUFileList();