You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Heidi McClure <he...@polarisalpha.com> on 2018/06/27 23:21:04 UTC

Graph, GraphML, Gephi and Edge Labels

Hello,

I am trying to export graph data from a Solr index (version 7.2) in a format that can be imported to Gephi for visualization.  I'm getting close!  Is there a way to add edge labels to the exports from this type of command (see curl command that follows and sample outputs)?

Thanks in advance,
-heidi

Based on the examples found here: https://lucene.apache.org/solr/guide/7_2/graph-traversal.html , this is working in my GDELT-based data set query request:

curl --data-urlencode 'expr=nodes(gdelt_graph,
                                  nodes(gdelt_graph,
                                        walk="POLICE->Actor1Name_s",
                                        trackTraversal="true",
                                        gather="Actor2Name_s"),
                                  walk="node->Actor1Name_s",
                                  scatter="leaves,branches",
                                  trackTraversal="true",
                                  gather="Actor2Name_s")' http://mymachine:8983/solr/gdelt_graph/graph

Output is like this (just a subset):
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<graph id="G" edgedefault="directed">
<node id="POLICE">
<data key="field">node</data>
<data key="level">0</data>
</node>
<edge id="1"  source="BANGLADESH"  target="POLICE"/>
<node id="HOSPITAL">
<data key="field">Actor2Name_s</data>
<data key="level">1</data>
</node>
<edge id="2"  source="POLICE"  target="HOSPITAL"/>
<node id="UNITED STATES">
<data key="field">Actor2Name_s</data>
<data key="level">1</data>
</node>
<edge id="3"  source="UNITED STATES"  target="UNITED STATES"/>
<edge id="4"  source="AFRICA"  target="UNITED STATES"/>
<edge id="5"  source="POLICE"  target="UNITED STATES"/>

And I'd like to have a key for label and the data tag on the edges so that I can get the Labels into Gephi.  Does anyone know if this can be done?  Below is example of what I mean.  Notice the key for label at the top of the file and the "This is an edge description" entries on two of the edges (ids 1 and 2).

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
    <key id="label" for="edge" attr.name="label" attr.type="string"/>
    <graph id="G" edgedefault="directed">
        <node id="POLICE">
            <data key="field">node</data>
            <data key="level">0</data>
        </node>
        <edge id="1"  source="BANGLADESH"  target="POLICE" label="foo">
            <data key="label">This is an edge description.</data>
        </edge>
        <node id="HOSPITAL">
            <data key="field">Actor2Name_s</data>
            <data key="level">1</data>
        </node>
        <edge id="2"  source="POLICE"  target="HOSPITAL">
            <data key="label">This is an edge description.</data>
        </edge>
        <node id="UNITED STATES">
            <data key="field">Actor2Name_s</data>
            <data key="level">1</data>
        </node>
        <edge id="3"  source="UNITED STATES"  target="UNITED STATES"/>
        <edge id="4"  source="AFRICA"  target="UNITED STATES"/>
        <edge id="5"  source="POLICE"  target="UNITED STATES"/>


Re: Graph, GraphML, Gephi and Edge Labels

Posted by Heidi McClure <he...@polarisalpha.com>.
Ok. Will do. I saw the place in the code, but haven’t managed to get the code to build, yet. 

> On Jun 29, 2018, at 9:03 AM, Joel Bernstein <jo...@gmail.com> wrote:
> 
> Hi,
> 
> Currently the nodes expression doesn't have this capability. Feel free to
> make a feature request on jira. This sounds like a fairly easy feature to
> add.
> 
> 
> 
> Joel Bernstein
> http://joelsolr.blogspot.com/
> 
> On Wed, Jun 27, 2018 at 5:21 PM, Heidi McClure <
> heidi.mcclure@polarisalpha.com> wrote:
> 
>> Hello,
>> 
>> I am trying to export graph data from a Solr index (version 7.2) in a
>> format that can be imported to Gephi for visualization.  I'm getting
>> close!  Is there a way to add edge labels to the exports from this type of
>> command (see curl command that follows and sample outputs)?
>> 
>> Thanks in advance,
>> -heidi
>> 
>> Based on the examples found here: https://lucene.apache.org/
>> solr/guide/7_2/graph-traversal.html , this is working in my GDELT-based
>> data set query request:
>> 
>> curl --data-urlencode 'expr=nodes(gdelt_graph,
>>                                  nodes(gdelt_graph,
>>                                        walk="POLICE->Actor1Name_s",
>>                                        trackTraversal="true",
>>                                        gather="Actor2Name_s"),
>>                                  walk="node->Actor1Name_s",
>>                                  scatter="leaves,branches",
>>                                  trackTraversal="true",
>>                                  gather="Actor2Name_s")'
>> http://mymachine:8983/solr/gdelt_graph/graph
>> 
>> Output is like this (just a subset):
>> <?xml version="1.0" encoding="UTF-8"?>
>> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
>> http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
>> <graph id="G" edgedefault="directed">
>> <node id="POLICE">
>> <data key="field">node</data>
>> <data key="level">0</data>
>> </node>
>> <edge id="1"  source="BANGLADESH"  target="POLICE"/>
>> <node id="HOSPITAL">
>> <data key="field">Actor2Name_s</data>
>> <data key="level">1</data>
>> </node>
>> <edge id="2"  source="POLICE"  target="HOSPITAL"/>
>> <node id="UNITED STATES">
>> <data key="field">Actor2Name_s</data>
>> <data key="level">1</data>
>> </node>
>> <edge id="3"  source="UNITED STATES"  target="UNITED STATES"/>
>> <edge id="4"  source="AFRICA"  target="UNITED STATES"/>
>> <edge id="5"  source="POLICE"  target="UNITED STATES"/>
>> 
>> And I'd like to have a key for label and the data tag on the edges so that
>> I can get the Labels into Gephi.  Does anyone know if this can be done?
>> Below is example of what I mean.  Notice the key for label at the top of
>> the file and the "This is an edge description" entries on two of the edges
>> (ids 1 and 2).
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
>> http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
>>    <key id="label" for="edge" attr.name="label" attr.type="string"/>
>>    <graph id="G" edgedefault="directed">
>>        <node id="POLICE">
>>            <data key="field">node</data>
>>            <data key="level">0</data>
>>        </node>
>>        <edge id="1"  source="BANGLADESH"  target="POLICE" label="foo">
>>            <data key="label">This is an edge description.</data>
>>        </edge>
>>        <node id="HOSPITAL">
>>            <data key="field">Actor2Name_s</data>
>>            <data key="level">1</data>
>>        </node>
>>        <edge id="2"  source="POLICE"  target="HOSPITAL">
>>            <data key="label">This is an edge description.</data>
>>        </edge>
>>        <node id="UNITED STATES">
>>            <data key="field">Actor2Name_s</data>
>>            <data key="level">1</data>
>>        </node>
>>        <edge id="3"  source="UNITED STATES"  target="UNITED STATES"/>
>>        <edge id="4"  source="AFRICA"  target="UNITED STATES"/>
>>        <edge id="5"  source="POLICE"  target="UNITED STATES"/>
>> 
>> 

Re: Graph, GraphML, Gephi and Edge Labels

Posted by Joel Bernstein <jo...@gmail.com>.
Hi,

Currently the nodes expression doesn't have this capability. Feel free to
make a feature request on jira. This sounds like a fairly easy feature to
add.



Joel Bernstein
http://joelsolr.blogspot.com/

On Wed, Jun 27, 2018 at 5:21 PM, Heidi McClure <
heidi.mcclure@polarisalpha.com> wrote:

> Hello,
>
> I am trying to export graph data from a Solr index (version 7.2) in a
> format that can be imported to Gephi for visualization.  I'm getting
> close!  Is there a way to add edge labels to the exports from this type of
> command (see curl command that follows and sample outputs)?
>
> Thanks in advance,
> -heidi
>
> Based on the examples found here: https://lucene.apache.org/
> solr/guide/7_2/graph-traversal.html , this is working in my GDELT-based
> data set query request:
>
> curl --data-urlencode 'expr=nodes(gdelt_graph,
>                                   nodes(gdelt_graph,
>                                         walk="POLICE->Actor1Name_s",
>                                         trackTraversal="true",
>                                         gather="Actor2Name_s"),
>                                   walk="node->Actor1Name_s",
>                                   scatter="leaves,branches",
>                                   trackTraversal="true",
>                                   gather="Actor2Name_s")'
> http://mymachine:8983/solr/gdelt_graph/graph
>
> Output is like this (just a subset):
> <?xml version="1.0" encoding="UTF-8"?>
> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
> http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
> <graph id="G" edgedefault="directed">
> <node id="POLICE">
> <data key="field">node</data>
> <data key="level">0</data>
> </node>
> <edge id="1"  source="BANGLADESH"  target="POLICE"/>
> <node id="HOSPITAL">
> <data key="field">Actor2Name_s</data>
> <data key="level">1</data>
> </node>
> <edge id="2"  source="POLICE"  target="HOSPITAL"/>
> <node id="UNITED STATES">
> <data key="field">Actor2Name_s</data>
> <data key="level">1</data>
> </node>
> <edge id="3"  source="UNITED STATES"  target="UNITED STATES"/>
> <edge id="4"  source="AFRICA"  target="UNITED STATES"/>
> <edge id="5"  source="POLICE"  target="UNITED STATES"/>
>
> And I'd like to have a key for label and the data tag on the edges so that
> I can get the Labels into Gephi.  Does anyone know if this can be done?
> Below is example of what I mean.  Notice the key for label at the top of
> the file and the "This is an edge description" entries on two of the edges
> (ids 1 and 2).
>
> <?xml version="1.0" encoding="UTF-8"?>
> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
> http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
>     <key id="label" for="edge" attr.name="label" attr.type="string"/>
>     <graph id="G" edgedefault="directed">
>         <node id="POLICE">
>             <data key="field">node</data>
>             <data key="level">0</data>
>         </node>
>         <edge id="1"  source="BANGLADESH"  target="POLICE" label="foo">
>             <data key="label">This is an edge description.</data>
>         </edge>
>         <node id="HOSPITAL">
>             <data key="field">Actor2Name_s</data>
>             <data key="level">1</data>
>         </node>
>         <edge id="2"  source="POLICE"  target="HOSPITAL">
>             <data key="label">This is an edge description.</data>
>         </edge>
>         <node id="UNITED STATES">
>             <data key="field">Actor2Name_s</data>
>             <data key="level">1</data>
>         </node>
>         <edge id="3"  source="UNITED STATES"  target="UNITED STATES"/>
>         <edge id="4"  source="AFRICA"  target="UNITED STATES"/>
>         <edge id="5"  source="POLICE"  target="UNITED STATES"/>
>
>