Re: [jgrapht-users] Extending Default Edge
Brought to you by:
barak_naveh,
perfecthash
From: Ricardo R. <ric...@gm...> - 2011-02-23 00:43:05
|
Hi... SimpleGraph does allow more than one edge for nodes, what it does not allow is more than one edge between two specific nodes. For instance, the following relations are allowed by SimpleGraphs: edge1: node1 - node2 edge2: node1 - node3 And the following relations are not: edge1: node1 - node2 edge2: node1 - node2 So... unless you want more than one edge between a specific pair, I think you can still use SimpleGraph... Regards, 2011/2/22 Neal Lewis <im...@gm...> > I ran into a problem with using the grammatical relations between nodes as > the edges and words as the nodes. I have tried with a Simple Graph, > MultipGraph, and PseudoGraph. > > I implemented it in this fashion : > > public class DependencyGraph extends SimpleGraph<TreeGraphNode, > GrammaticalRelation> > > public DependencyGraph(ArrayList<TypedDependency> tdl ) > { > super(GrammaticalRelation.class); > this.tdl = tdl; > this.tree =null; > > //build dependency graph from tdl; > for (TypedDependency td : tdl) { > this.addVertex(td.gov()); > this.addVertex(td.dep()); > this.addEdge(td.gov(), td.dep(), td.reln()); > } > } > > This works great because I can just grab the edge between to TreeGraphNodes > and understand the relationship. > > However, Because this is perhaps a SimpleGraph (or Multigraph, or > PseudoGraph), it will not lot me have more than on grammatrical relation > edge (I imagine it would be the same if I used Strings as the edge > types). Even though the edge is named "amod", if there are more than one > "amod" relationships in the the typedDependencyList, these graphs wont load > them. > > I am converting the whole typedDependencyList to an undirectedGraph. > > So basically, I want to be able to have more than one edge of the same > name, but with no cycles > > > Is there a graph I can use that would make this work? Or should I just > stick with the default edges? > > Thanks! > Neal > > > On 02/10/2011 08:10 PM, Neal Lewis wrote: > > That's fantastic! I didn't realize this API was so flexible. Thanks for > an awesome API! > > -Neal > > On 02/10/2011 07:41 PM, Ricardo Redder wrote: > > Hi, > > From the sample in project page: > http://nlp.stanford.edu/software/lex-parser.shtml#Sample > > I imagine the TypedDependencies are: > det(rain-3, > The-1) > amod(rain-3, > strongest-2) > nsubj(shut-8, > rain-3) > ... > > > > > And, by dependecy relations, I understand: det, amod, nsubj, etc.. > > So... if that's the case, you don't need to use the class DefaultEdge as a > type for your edges or extend it, JGraphT is based on Generics... so you can > use whatever class which is suitable for you... > E.g.: > > SimpleGraph<String, String> graph = new SimpleGraph<String, > String>(String.class); > > So you can add edges with the desired information: > graph.addEdge("rain-3", "The-1", "det"); > graph.addEdge("rain-3", "strongest-2", "amod"); > graph.addEdge("shut-8", "rain-3", "nsubj"); > > Probably your vertices and edges are not String's, so you just have to > choose the right class for your graphs... > I hope I could help you. > > Regards > > 2011/2/9 Neal Lewis <im...@gm...> > >> Hello, >> >> First off, thanks for such a great API. This had made my life much, >> much easier. >> >> I am applying the graphs to output from the Stanford Parser API, and >> creating SimpleGraphs Undirected from the TypedDependencies output from >> the Stanford Parser. I would like to use the dependency relations as >> edges in the graph, such that I can create a GraphPath of label edges. >> >> Is this possible? Has it been down before? >> >> Thank you! >> >> Neal >> >> >> ------------------------------------------------------------------------------ >> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: >> Pinpoint memory and threading errors before they happen. >> Find and fix more than 250 security defects in the development cycle. >> Locate bottlenecks in serial and parallel code that limit performance. >> http://p.sf.net/sfu/intel-dev2devfeb >> _______________________________________________ >> jgrapht-users mailing list >> jgr...@li... >> https://lists.sourceforge.net/lists/listinfo/jgrapht-users >> > > > > -- > Redder > > > > -- Redder |