← Back to list

Social Network Analysis — Part1: Foundation & Types of Graphs.

A key technique in modern sociology to investigate social structures through networks and graph theory.

AI & Data Science 604 · 2026-08-27 15:20 · 1 claps · 12.6 min read
#social-network-analysis #data-analysis #social-network #network-visualization
Open on Medium ↗
Wiki topics: SOC · Sociology & Politics 🔒 · Cybersecurity 🌐 · Society · General

Social Network Analysis — Part1: Foundation & Types of Graphs.

A key technique in modern sociology to investigate social structures through networks and graph theory.

This series equip you with the skills to analyze, visualize, and make sense of networks. We’ll apply the concepts to real-world network data using the powerful NetworkX library. With the knowledge gained in this seris, we’ll develop our network thinking skills and be able to look at your data with a fresh perspective.

What is Social Network Analysis (SNA)?

When we hear the term social network (SN), we often think about social media platform platforms e.g., Facebook, LinkedIn or X. But in data science, SN is much broader than a social media platform. It is about relationships between entities. SN is essentially a system of entities connected to each other through relationships or interactions. The entities can be people, organizations, websites, computers, countries, or even scientific papers. The connections can represent friendship, communication, collaboration, transactions, following, citations, or many other types of relationships. This makes SN a powerful source of information.

A SN can be represented mathematically as a graph consisting of Nodes (vertices), which are the entities in the network and Edges (links), which are the relationships or interactions between those entities.

I.e., imagine a network of employees in a company. Each employee can be represented as a node, while an interaction between 2 employees e.g., sending an email or working on the same project can be represented as an edge.

What Information Can We Get from a SN?

The interesting part of a network is not simply knowing who is connected to whom. The structure of those connections can reveal information that may be difficult to discover by looking at individual records independently.

One of the 1st questions we can ask is: Who are the most important people in this network (Most Important or Influential Nodes)? Where the importance can have different meanings. I.e.,

  • A person might have connections to many other people. This can be measured using degree centrality.
  • Another person may not have many connections, but they may connect two otherwise separate groups. Such a person can have high betweenness centrality.
  • There are also measures such as closeness centrality and PageRank that capture other types of importance.

Networks often contain groups of nodes that are more strongly connected to each other than to the rest of the network. These groups are called communities or clusters. I.e., in a professional network, we might discover communities corresponding to Data scientists, Software engineers, Financial analysts and Marketing professionals

Without manually labeling every person, a community detection algorithm may discover these groups from the structure of the network itself.

This is particularly useful because network structure can reveal hidden groups and organizational structures.

Networks can also help us understand information diffusion and spread. I.e., Imagine a piece of information being shared across a social network. We can ask: Who is likely to see it first? Who can spread it to a large audience? Which communities will receive it? How quickly can it spread and Where might the information stop spreading?

This can be useful for studying everything from viral content and marketing campaigns to misinformation and emergency communication. The important insight is that the structure of the network affects how information moves through it.

Networks are everywhere around you, knowing how to analyze them will be a powerful toolkit and will open up a new world of possibilities. From online social networks e.g., Facebook to the intersection of biological network, science and infectious disease to transportation networks modeling the connectivity between locations determined by roads, flight or paths connecting them, e.g., bike sharing systems.

Network Structure.

Networks-at its core-are described by 2 sets of items which are nodes and edges for modeling the relationships between entities. These nodes and edges together form a “network”, otherwise known in mathematical terms as a “graph”. In addition, Nodes and edges can have metadata associated with them.

By modeling your data as a network, you can end up with:

  • gaining insight into what entities (or nodes) are important e.g., broadcasters or influencers in a social network.
  • We can start to think about optimizing transportation between cities.

I.e., say there’re 2 friends, Hugo and Eric, who met on the 21st of May, 2016.

In this case, these nodes with metadata stored in a key-value pair as id:age and date, which represents the date on which they first met.

Types of graphs.

Not all networks represent relationships in the same way. Depending on the nature of the relationships, we can represent a network using different types of graphs.

Understanding these graph types is important because the structure of the graph determines which algorithms and network metrics we can use.

1- Undirected graphs.

Undirected graphs are comprised of edges that don’t have any inherent directionality associated with them.

I.e., there’re social graphs e.g., Facebook. As when one user befriends another, the 2 are automatically connected with an edge. This is commonly drawn as a line with no arrows between two circles.

2- Directed graphs.

In a directed graph, relationships have a specific direction. There’s an inherent directionality associated with the graph.

I.e., Twitter’s social graph is a directed network. As the nature of how users interact with one another. One user may follow another, but that other don’t.

Direction can provide important information. I.e., in a citation network, a paper can cite another paper, but the reverse relationship does not automatically exist.

3- Multi-edge (Directed) graphs.

A multigraph allows multiple edges between the same 2 nodes. I.e., A interacts with B through different channels:

A ──  email ---->  B
A ── phone ---->   B
A ── WhatsApp ---> B

Instead of representing all of these interactions as one relationship, a multigraph can preserve the different types of connections. This can be useful when analyzing multiplex or multilayer relationships.

Here, there are 3 distinct edges between Alice and Bob. Each edge can represent a different relationship or interaction. Multiple relationships between the same nodes = multi-edge graph. Two or more edges connecting the same 2 vertices within a multigraph.

One more example, we may want to model trips between flight, each flight may be an edge between the pair of airports.

4- Self-loops.

A self-loop (also called a self-edge) is an edge that connects a node to itself (Nodes that are connected to themselves).

Self-loops can be used in certain scenarios

Self-loops can be used in certain scenarios

For example, a user posts something and then interacts with her own post. One more example, in bike sharing data, where a trip begins at a station and end at the same station. Imagine a directed graph where Nodes are webpages and Edges are hyperlinks. Normally: Page A → Page B. A self-loop occurs when: Page A → Page A meaning the page contains a hyperlink that points back to itself.

However, whether self-loops are allowed depends on the type of network. In many social networks, such as friendship networks, self-loops are usually meaningless and are therefore excluded.

A self-loop is not a separate graph type in the same sense as “weighted graph” or “directed graph.” It is a property/feature of a graph. A graph can be simultaneously directed, weighted, and contain self-loops.

Why Do These Types Matter?

Choosing the correct graph representation is not just a technical detail. Imagine we are analyzing Twitter/X followers. Treating the network as undirected would lose the important fact that: A follows B ≠ B follows A

Similarly, if we analyze financial transactions but ignore transaction amounts, we lose information that could be critical for detecting fraud.

Therefore, before applying Social Network Analysis, we need to understand: What do the nodes represent? What do the edges represent? And what information does each edge carry?

Once we answer these questions, we can choose an appropriate graph representation — and then apply network analysis techniques to extract meaningful insights from it.

Weights on graphs

For collapsing the edges into a single edge that contains a metadata summary of the original. For example, we may want to collapse these three edges into a single one and give them a “weight” metadata. with the value “3”, indicating that it was originally 3 edges between the pair of nodes.

Weights could be:

  • Frequency of interaction in period of observation.
  • Number of items exchanged in period.
  • Individual perceptions of strength of relationship.
  • Costs in communication or exchange, e.g. distance.
  • Combinations of multiple factors.

What are the differences between weighted Graph and Multi-edge graphs?

While both graph types capture rich interactions in Social Network Analysis (SNA), they handle edge data differently. A Weighted Graph aggregates interactions into a single numerical score per connection, whereas a Multi-edge Directed Graph (Multigraph) preserves discrete, individual interaction events with their own metadata (e.g., timestamps or interaction types).

Weighted Directed Graph

  • Best for: High-level summary of tie strength.
  • Example: Modeling an email network where Node A and Node B are connected by one directed edge with a weight = 15 (representing 15 total emails sent from A to B).

Multi-edge Directed Graph

  • Best for: Granular, temporal, or multi-modal analysis.
  • Example: Modeling an email network where Node A and Node B are connected by 15 distinct directed edges, each containing individual attributes like Timestamp: 2026-03-01 10:00 AM, Subject: Budget Review, and Sentiment: Urgent.

When to Use Which

  • Choose a Weighted Graph when calculating standard social metrics like weighted degree centrality, shortest paths, or community detection.
  • Choose a Multi-edge Graph when analyzing how social interactions unfold over time, comparing different communication channels (e.g., retweets vs. direct replies), or tracking individual transaction flows.

(Note: Analysts frequently start with a multi-edge graph to collect raw event logs and aggregate it into a Weighted graph for downstream SNA algorithms.)

Predicting Missing or Future Connections.

Suppose 2 people are not currently connected. Can we predict whether they are likely to become connected in the future? This is known as link prediction. I.e., LinkedIn might recommend: “People you may know.”

The recommendation can use information about existing connections and the structure of the network. If 2 users have many common connections, for example, they may have a higher probability of becoming connected. This turns network analysis from a descriptive tool into a predictive tool.

One important application of SNA is link prediction: using the structure of an existing network to predict connections that are missing today or are likely to appear in the future.

This idea is particularly important in recommendation systems, where platforms can use information about users’ existing relationships and interactions to recommend people, products, content, or communities that a user may be interested in.

In a real network, not every possible relationship is observed. Two people may know each other but have not connected on the platform, or they may be likely to connect in the future.

Link prediction attempts to estimate: How likely is it that two currently unconnected nodes will have a connection?

I.e., suppose Alice and Bob are not connected, but they have 5 mutual friends. The network structure provides evidence that Alice and Bob might know each other.

The system can therefore assign a high probability to the potential connection: Alice → Bob: High likelihood of connection

Missing connections

A connection may already exist in reality but is not present in the available network data. I.e., Alice and Bob work together, but Bob has not added Alice on the social platform. The algorithm tries to identify this hidden relationship based on the network’s structure.

Future connections

A connection does not exist yet, but the network structure suggests that it is likely to form. I.e., Alice and Bob have several mutual friends and interact with the same communities. The system predicts that they may connect in the future. So, link prediction can be thought of as: Existing network → Analyze structure → Identify likely missing/future links

“Friends of Friends” as a Simple Example. One of the simplest forms of link prediction is based on Common Neighbors.

Alice ─── Sarah ─── Bob
  \        │        /
   ──── Michael ───

Alice and Bob are not directly connected. However, they share Sarah and Michael as mutual connections. Therefore Alice and Bob have 2 common neighbors → relatively high likelihood of connection. This is the basic intuition behind features such as “People You May Know.”

The underlying idea is People who share many connections are often more likely to connect. However, real recommendation systems generally use many more signals than simply counting mutual friends.

Several network-based measures can be used to calculate the likelihood of a connection.

Common Neighbors

Counts how many neighbors two nodes have in common.

where Γ(A) represents the neighbors of node A. More common neighbors → potentially higher likelihood of a connection.

Jaccard Coefficient

The Jaccard coefficient compares the shared neighbors with the total number of unique neighbors:

This is useful when users have very different numbers of connections.

Adamic–Adar Index

Adamic–Adar gives more importance to rare common neighbors. The intuition is that having a rare connection in common can provide stronger evidence of similarity than sharing a very popular person.

Preferential Attachment

This measure is based on the idea that highly connected nodes are more likely to acquire new connections.

For example, if 2 highly connected users are not connected, the preferential-attachment score may be relatively high.

SNS in Recommendation Systems

This is where the concept becomes especially powerful. Instead of recommending something solely based on the item’s properties, a recommendation system can exploit the relationships between users and items. I.e., consider an e-commerce network:

Users             Products

Alice ───────────► Laptop
  │
  ├──────────────► Mouse
  │
  └──────────────► Keyboard

Bob ─────────────► Laptop
  │
  └──────────────► Keyboard

If Alice and Bob have similar interaction patterns, the system can infer that Alice may also be interested in products that Bob interacted with. This can lead to recommendations such as: “You may also like this product.”

Link prediction can be applied to many types of recommendation problems:

For example, on a social platform, the system might predict: User → Person while on a movie platform it might predict User → Movie. The underlying principle is similar: predict an unobserved or future edge based on patterns in the network.

Detect Anomalies.

Network analysis can also help identify unusual behavior. I.e., Imagine a financial transaction network where Nodes represent bank accounts and Edges represent money transfers.

A normal account might have a relatively predictable pattern of transactions. However, an account suddenly connected to hundreds of previously unrelated accounts may represent an unusual pattern.

Network-based anomaly detection can therefore be useful in areas e.g, Fraud detection, Cybersecurity, Financial crime detection, Fake account detection and Bot detection

The key advantage is that we are not only analyzing what an entity does, but also how it is connected to other entities.

Why Do We Need to Analyze Social Networks?

A traditional dataset often represents each entity as an independent row.

This can tell us a lot about individual users. But what if the important information is actually in the relationships between them? Consider two users with exactly the same demographic characteristics. One might be highly connected to influential people, while the other belongs to an isolated community. A traditional tabular analysis may treat them as similar. A network analysis can reveal that they occupy completely different positions in the system. This is the fundamental reason we analyze networks; Relationships contain information.

Social Network Analysis as a Data Science Toolkit

This is where Social Network Analysis becomes particularly interesting for data scientists. SNA combines ideas from several areas:

Graph Theory + Statistics + Machine Learning + Data Analysis + Visualization

A data scientist working with network data may need to Collect network data Represent the data as graphs Clean and preprocess nodes and edges Calculate network metrics Detect communities Visualize network structures Identify important nodes Detect anomalies Build predictive models Interpret the results.

This makes SNA more than a visualization technique. It is a way of thinking about data. Instead of asking only: “What characteristics does this entity have?”

we can also ask: “Who is this entity connected to? How strong are those connections? What position does it occupy? Which communities does it belong to? How does information or behavior move through the network? These questions can reveal patterns that traditional tabular analysis may completely miss.

One of the most important lessons from Social Network Analysis is that data is not always independent. e.g., People influence people, Companies collaborate with companies, Websites link to websites, Banks transfer money between accounts, Researchers cite other researchers and Users interact with other users.

In all of these cases, the relationships themselves become data. And once we represent those relationships as a network, we can use mathematical and computational techniques to uncover structure, influence, communities, patterns, and anomalies. That is why Social Network Analysis is a valuable addition to a data scientist’s toolkit.

It teaches us to look at data not only as a collection of individual observations, but as a connected system in which the relationships between entities can be just as important as the entities themselves.


메타데이터
post_id
af5b3ccd8bef
slug
social-network-analysis-part1-foundation-types-of-graphs-af5b3ccd8bef
url
https://medium.com/@Mustafa77/social-network-analysis-part1-foundation-types-of-graphs-af5b3ccd8bef
canonical_url
https://medium.com/@Mustafa77/social-network-analysis-part1-foundation-types-of-graphs-af5b3ccd8bef
author_url
https://medium.com/@Mustafa77
status
ok
fetched_at
2026-09-03 09:20:49