Class DynamicConnections
java.lang.Object
com.tnsai.coordination.groups.network.DynamicConnections
Manages dynamic peer-to-peer connections in a network mesh.
Thread-safe connection management with shortest path finding.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConnects two peers bidirectionally.voiddisconnect(String agentA, String agentB) Disconnects two peers bidirectionally.findShortestPath(String from, String to) Finds the shortest path between two agents using BFS.getConnectedPeers(String agentId) Returns the connected peers of an agent.intReturns the total number of connections.booleanisConnected(String agentA, String agentB) Checks if two agents are directly connected.voidremoveAgent(String agentId) Removes an agent and all its connections.
-
Constructor Details
-
DynamicConnections
public DynamicConnections()
-
-
Method Details
-
connect
Connects two peers bidirectionally.- Parameters:
agentA- first agent IDagentB- second agent ID
-
disconnect
Disconnects two peers bidirectionally.- Parameters:
agentA- first agent IDagentB- second agent ID
-
getConnectedPeers
Returns the connected peers of an agent.- Parameters:
agentId- agent ID- Returns:
- set of connected peer IDs
-
isConnected
Checks if two agents are directly connected.- Parameters:
agentA- first agentagentB- second agent- Returns:
- true if directly connected
-
findShortestPath
Finds the shortest path between two agents using BFS.- Parameters:
from- source agent IDto- target agent ID- Returns:
- list of agent IDs forming the path, or empty if no path exists
-
removeAgent
Removes an agent and all its connections.- Parameters:
agentId- agent to remove
-
getConnectionCount
public int getConnectionCount()Returns the total number of connections.- Returns:
- connection count (each bidirectional connection counted once)
-