-
Notifications
You must be signed in to change notification settings - Fork 0
5 Understanding Node Degree
swhitenstall edited this page Jan 30, 2025
·
1 revision
Node Degree is a fundamental metric in graph analysis that measures how connected a node is. Think of it as counting a node's relationships.
// Basic Node Degree Analysis
MATCH (n)
OPTIONAL MATCH (n)-->(out)
OPTIONAL MATCH (n)<--(in)
OPTIONAL MATCH (n)--(total)
RETURN
labels(n)[0] as NodeType,
CASE labels(n)[0]
WHEN 'Person' THEN n.name
WHEN 'Meeting' THEN n.workgroup + ' (' + n.date + ')'
ELSE coalesce(n.title, n.text, '')
END as NodeName,
count(DISTINCT out) as OutDegree, // Outgoing relationships
count(DISTINCT in) as InDegree, // Incoming relationships
count(DISTINCT total) as TotalDegree // All relationships
ORDER BY TotalDegree DESC;-
Out-Degree
- Number of outgoing relationships
- Example: Person -[ATTENDED]-> Meeting
- Shows: How many meetings a person attended
-
In-Degree
- Number of incoming relationships
- Example: Meeting <-[ATTENDED]- Person
- Shows: How many people attended a meeting
-
Total Degree
- Total number of relationships (both directions)
- Shows: Overall connectivity of a node
// Example: Meeting Attendance Degree
MATCH (m:Meeting)
OPTIONAL MATCH (m)<-[att:ATTENDED]-(p:Person)
OPTIONAL MATCH (m)-[act:HAS_ACTION]->(a:ActionItem)
RETURN
m.workgroup + ' (' + m.date + ')' as Meeting,
count(DISTINCT p) as Attendees, // In-Degree for ATTENDED
count(DISTINCT a) as ActionItems, // Out-Degree for HAS_ACTION
count(DISTINCT p) + count(DISTINCT a) as TotalConnections
ORDER BY TotalConnections DESC;
// Example: Person Activity Degree
MATCH (p:Person)
OPTIONAL MATCH (p)-[att:ATTENDED]->(m:Meeting)
OPTIONAL MATCH (p)<-[assigned:ASSIGNED_TO]-(a:ActionItem)
RETURN
p.name as Person,
count(DISTINCT m) as MeetingsAttended, // Out-Degree for ATTENDED
count(DISTINCT a) as AssignedActions, // In-Degree for ASSIGNED_TO
count(DISTINCT m) + count(DISTINCT a) as TotalActivity
ORDER BY TotalActivity DESC;-
High Degree Nodes
- Meetings with many attendees
- People involved in many meetings
- Topics discussed frequently
-
Low Degree Nodes
- One-off meetings
- Occasional participants
- Rarely discussed topics
-
Business Insights
- Identify key participants
- Find important meetings
- Discover central topics