All posible paths between 2 nodes in gephi - gephi

is there any way to find all paths with the maximum length of 2 and less between 2 nodes or 2 modules with filters in gephi?
1)I tried using an intersection on 2 ego networks (each for one node) is it right or am i missing something?
2)how is it possible to find paths between 2 modules? (or getting the ego network of a module)

Related

Neo4j OSM Intersections and Spatial Graph Setup

I've been trying to setup Neo4j for use as a routing engine, and this has lead to two questions (amongst others).
Main Question
When following the instructions from the README, after importing the OSM data, the next step is to identify intersections, as shown below:
MATCH (n:OSMNode)
WHERE size((n)<-[:NODE]-(:OSMWayNode)-[:NEXT]-(:OSMWayNode)) > 2
AND NOT (n:Intersection)
WITH n LIMIT 100
MATCH (n)<-[:NODE]-(wn:OSMWayNode), (wn)<-[:NEXT*0..100]-(wx),
(wx)<-[:FIRST_NODE]-(w:OSMWay)-[:TAGS]->(wt:OSMTags)
WHERE exists(wt.highway)
SET n:Intersection
RETURN count(*);
I haven't figured out how the >2 works in the second line, WHERE size((n)<-[:NODE]-(:OSMWayNode)-[:NEXT]-(:OSMWayNode)) > 2.
Can anyone explain how this works?
I think it filters for connections to a node, where an intersection should be more than 2 connections (because it has to have multiple roads there to "intersect"). However, if there's only 2 roads at an intersection (i.e., the streets keep the same name when passing through the intersection), there seems to be only 1 connection from each street to the node, thus giving exactly 2 connections and failing the check. I want to believe I am missing something trivial here...
Secondary Question
I've been combining instructions from the README with the demo to build a routing graph. I'm certain these instructions are complete...in some fashion.
Are there more clear or updated instructions for building a routing graph in Neo4j?
References:
Similar question
2018 Graph Talk
Github repo
The function size() returns the number of elements in a list.
https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-size
What you mean would be the case if we only consider the following query:
size((n)<-[:NODE]-(:OSMWayNode)) > 2
This would only count the connected OSMWayNode and 'Street-Links' would be classified as intersections.
But because the next OSMWayNode appears in the list there can be multiple appereances for one [NODE] relation:
(n:OSMNode)<-[nr1:NODE]-(own1:OSMWayNode)-[wr1:NEXT]->(own2:OSMWayNode)
(n:OSMNode)<-[nr2:NODE]-(own3:OSMWayNode)-[wr2:NEXT]->(own4:OSMWayNode)
(n:OSMNode)<-[nr2:NODE]-(own3:OSMWayNode)<-[wr3:NEXT]-(own5:OSMWayNode)
(note that the [:NEXT]-relations are bidirectional in the query)
example of an intersection in munich
This shows two crossing roads leading to an intersection rather than a link

Why so many db hit in neo4j?

There is total 1 Category node and 2 Template node in my case. I put an * in [*] to support more further scenarios. But why there are so many db hit in this cypher for current data?
It's probably the * in the relationship part of your query that's doing it.
While you've got only one Category node and two Template nodes, you've asked Neo4j to hop through any number of relationships to get from one to the other and not given it any help to narrow down the search besides specifying the starting node.
For example, if your Category was connected to 100,000 other nodes (of any label, not just Template) you've forced Neo4j to jump through every single one of them looking to see if there's a path to a Template node - and if those nodes have their own connections then they all need to be explored too, because the depth of the traversal isn't constrained.
If you know how Category and Template nodes can be connected in ways you're interested in (for example, if there's only every some specific set of relationships you want to traverse) then you'll radically improve the performance of the query. Equally, reducing the maximum length of the path will help.

With neo4j's Cypher how can I find disconnected node groups with a maximum group diameter of 3

In neo4j I have a graph with disconnected groups (i.e. the nodes of
one group have no links to any nodes in another group).
Most of the nodes in the build one large group with many links and a
large group diameter. (As group diameter I describe the graph
diameter of the
group as a separate graph.) However I know there are a few other
groups of nodes in the total graph with a group diameter of only 3.
Here a visualisation of a sample network:
This graph has a large group (in blue) with diameter 11 and two small groups (in green) with diameter 3.
How can I find these smaller groups with a Cypher query?
To find those clusters, it's an heavy operation ...
For each node, you need to :
search if a path with a length of 4 exists
if it doesn't exist, to make a graph traversal with a max depth of 3.
With that you will find the cluster for each node.
Instead of doing that by yourself, I recoomend you to take a look at the graph-algo plugin, you will find some algo to performs community detection.

Graph: Creating shortest marked path to connect two nodes

Given an undirected, unweighted graph in which some nodes are marked, is there an efficient way to find the unmarked nodes between node A and B which would create a "marked" path from A to B when they are marked? The number of those "bridge" nodes should be minimal.
For example, in the graph below there would be two minimal ways to connect node A to B. One possibility would be to mark the node labelled 1, the other possibility would be to mark node 2.
Convert your graph into a directed, weighted graph such that:
the weight of each edge going into a marked node is set to 0
the weight of each edge going into an unmarked node is 1
Find all lowest-cost paths from A to B.

Is it possible to find all paths between minimum and maximum cost in neo4j?

I have a neo4j database with around 10 million nodes. They are connected through relationships with a property "weight". I want to find the paths between a starting node and the target node based on the minimum and maximum cost (through "weight" property). I am using Java so I have explored GraphAlgoFactory and Dijkstra classes. Dijkstra will only give me multiple paths but with the minimum cost. But I want multiple paths which cost higher than the cost of shortest path.
Lets say there are multiple paths between two nodes A and B. The cost of minimum path is 20 (with 4 nodes). But I want all paths with cost 25 to 30. Is it possible?
Any help would be appreciated...
Not sure about Java, but you can aggregate data from a path in Cypher.
You first MATCH the start and end node with [*1..n] relationships and then RETURN all paths and the aggregated (i.e. reduced) weights on the relationships in this path.
Something along this line:
MATCH path = (a:Node {some: 'property'})-[*1..10]-(b:Node {some: 'property'})
RETURN path, reduce(sum = 0, r IN relationships(path) | sum + r.weight) AS weight_sum
http://neo4j.com/docs/stable/query-functions-collection.html#functions-reduce

Resources