Class SocialNetwork
java.lang.Object
org.episteme.social.sociology.SocialNetwork
- All Implemented Interfaces:
Serializable, Graph<Person>, WeightedGraph<Person,Real>, Commented, ComprehensiveIdentification, Identified<Identification>, Named
public class SocialNetwork
extends Object
implements ComprehensiveIdentification, WeightedGraph<Person,Real>
Represents a social network graph where persons are nodes and relationships are edges.
Provides basic graph algorithms for social network analysis, such as degrees of separation.
Modernized to implement ComprehensiveIdentification and support edge weights.
* @version 1.2
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Graph
Graph.Edge<V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnection(Person p1, Person p2) Adds a bidirectional connection (relationship) between two people.voidaddConnection(Person p1, Person p2, double weight) voidaddConnection(Person p1, Person p2, Real weight) Adds a bidirectional weighted connection.booleanAdds a weighted edge to the graph.voidAdds a person to the network as a node.booleanAdds a vertex to the graph.booleanareConnected(Person p1, Person p2) Checks if two people are directly connected.intReturns the degree (number of edges) of a vertex.edges()Returns all edges in this graph.booleanCalculates the closeness centrality of a person.Calculates the local clustering coefficient of a person.Returns the default weight for unweighted edge additions.Calculates the degree centrality of a person.intgetDegreesOfSeparation(Person start, Person end) Finds the shortest path (degrees of separation) between two people using Breadth-First Search (BFS).getId()Returns the unique identifier of this entity.Returns the traits map for this entity.Returns the weight of an edge.Returns all weighted edges in the graph.getWeightedEdgesFrom(Person vertex) Returns weighted edges originating from a vertex.inthashCode()booleanChecks if this graph is directed.Returns neighbors of a vertex.toString()intReturns the number of vertices in the graph.vertices()Returns all vertices in this graph.Methods inherited from interface Commented
getComments, getTrait, setCommentsMethods inherited from interface ComprehensiveIdentification
getName, getTrait, setName, setTraitMethods inherited from interface WeightedGraph
addEdge, hasEdge
-
Constructor Details
-
SocialNetwork
-
-
Method Details
-
getId
Description copied from interface:IdentifiedReturns the unique identifier of this entity.- Specified by:
getIdin interfaceIdentified<Identification>- Returns:
- the identifier
-
getTraits
Description copied from interface:ComprehensiveIdentificationReturns the traits map for this entity.- Specified by:
getTraitsin interfaceCommented- Specified by:
getTraitsin interfaceComprehensiveIdentification- Returns:
- the traits map
-
vertices
-
edges
-
addVertex
-
addEdge
Description copied from interface:WeightedGraphAdds a weighted edge to the graph.Vertices are automatically added if not already present.
- Specified by:
addEdgein interfaceWeightedGraph<Person,Real> - Parameters:
source- the source vertextarget- the target vertexweight- the edge weight- Returns:
- true if the edge was added
-
neighbors
-
degree
-
isDirected
public boolean isDirected()Description copied from interface:GraphChecks if this graph is directed.- Specified by:
isDirectedin interfaceGraph<Person>- Returns:
- true if directed, false if undirected
-
vertexCount
public int vertexCount()Description copied from interface:GraphReturns the number of vertices in the graph.- Specified by:
vertexCountin interfaceGraph<Person>- Returns:
- the number of vertices
-
getWeight
Description copied from interface:WeightedGraphReturns the weight of an edge.- Specified by:
getWeightin interfaceWeightedGraph<Person,Real> - Parameters:
p1- the source vertexp2- the target vertex- Returns:
- the edge weight, or null if no such edge exists
-
getWeightedEdges
Description copied from interface:WeightedGraphReturns all weighted edges in the graph.- Specified by:
getWeightedEdgesin interfaceWeightedGraph<Person,Real> - Returns:
- unmodifiable set of weighted edges
-
getWeightedEdgesFrom
Description copied from interface:WeightedGraphReturns weighted edges originating from a vertex.- Specified by:
getWeightedEdgesFromin interfaceWeightedGraph<Person,Real> - Parameters:
vertex- the source vertex- Returns:
- set of weighted edges from vertex
-
getDefaultWeight
Description copied from interface:WeightedGraphReturns the default weight for unweighted edge additions.Used when addEdge(V, V) is called without a weight. Subclasses should override to provide appropriate default.
- Specified by:
getDefaultWeightin interfaceWeightedGraph<Person,Real> - Returns:
- the default weight (e.g., 1.0, Real.ONE)
-
addPerson
Adds a person to the network as a node.- Parameters:
p- the person to add
-
addConnection
-
addConnection
-
addConnection
-
areConnected
-
getDegreesOfSeparation
Finds the shortest path (degrees of separation) between two people using Breadth-First Search (BFS).- Parameters:
start- the starting personend- the target person- Returns:
- the number of hops (degrees), or 0 if same person, or -1 if no path exists
-
getDegreeCentrality
-
getClosenessCentrality
-
getClusteringCoefficient
-
getNeighbors
-
getPersons
-
equals
-
hashCode
-
toString
-