src/core/Graph.h

Graph [Class]

Description

The Graph class represents the social network structure using an adjacency list. It manages users (nodes) and their follower relationships (edges).

Public Methods

Graph(const std::string &content)
Constructs a graph by parsing the provided XML content.
Parameters
  • content: Raw XML string containing user data.
bool addEdge(int from, int to)
Adds a directed edge (following relationship) from one user to another.
Parameters
  • from: ID of the user following.
  • to: ID of the user being followed.
Returns
true if successful, false otherwise (e.g., edge already exists).
std::vector<int> getNeighbors(int from)
Retrieves a list of user IDs that the specified user is following.
Parameters
  • from: The unique ID of the user.
Returns
A vector of integers representing the IDs of followed users.
std::vector<int> getMostInfluencerId()
Identifies data for the most influential users (highest indegree).
Returns
Vector of IDs for the most influential users.
std::vector<int> getMostActivePersonId()
Identifies data for the most active users (highest outdegree).
Returns
Vector of IDs for the most active users.