Reputation: 407
I have two types of nodes in a graph DB. One type is Testplan
and the other is Tag
.
I want to find which Tag
nodes that have most connections across unique Testplan.TP_MNEM
(this is a property of Testplan
node).
To explain it in a bit more detail:
Let’s say the graph has 5 Testplan
nodes, 3 with TP_MNEM
as “AAA”, 1 with TP_MNEM
as “BBB” and the other with TP_MNEM
as “CCC”.
I want the Tag
nodes that are connected to most types of TP_MNEM
.
If a Tag
Node 1 has 3 connections with TP_MNEM
“AAA” and no connection with any other TP_MNEM
then Tag
Node 1 should get lower priority over Tag
Node 2 which has 2 connections but each with unique TP_MNEM
(“AAA” and “CCC”, for example).
Similarly I want the Tag
nodes having highest degree but are only connected to only one type of TP_MNEM. Here Tag Node 1 will get precedence over Tag Node 2.
The code to upload a CSV is shared below:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///C:/SRA_clean.csv" AS row
MERGE(testplan:Testplan{
TP_ID:row.TP_ID,
DB_NAME:row.DATABASE_NAME,
TP_MNEM:row.TP_MNEMONIC,
TEST_TYPE:row.TEST_TYPE,
TEST_PLAN_NAME:row.TEST_PLAN_NAME,
CREATION_DATE:row.TS_CREATION_DATE,
MODIFIED_DATE:row.TS_MODIFIED_DATE,
SQL_SERVE_UPD_DATE:row.UPDATE_DT_TM_SQL_SERV,
MYSQL_UPD_DATE:row.UPDATE_DT_TM_MY_SQL
})
FOREACH (tagName IN split(row.Keywords,",")|
MERGE (tag:Tag{name:tagName})
MERGE(testplan)-[:TAGGED]->(tag))
Any help would be great.
Upvotes: 1
Views: 48
Reputation: 2666
I may have simplified things (and/or misunderstood your questions) ... but doesn't the following query fulfill your first question ?
MATCH (tg:Tag)<-[:TAGGED]-(tp:Testplan)
RETURN tg.tagName, count(DISTINCT tp.TP_MNEM) AS count ORDER by count DESC;
And the other question ... well ... just replace DESC with ASC ...
Hope this helps.
Regards, Tom
Upvotes: 0