top of page
Search

Everything is Graphs and Poetry

  • Writer: Samuel Fernández Lorenzo
    Samuel Fernández Lorenzo
  • Jul 23
  • 5 min read

When I was in school, there was a teacher who told me something that, for some reason, became etched in my memory: "everything is matrices and poetry." Although his statement had a playful tone, I sensed that it concealed a profound truth. Today I'm going to appropriate it by saying that "everything is graphs and poetry," and with this explore their fascinating omnipresence across a multitude of applications.


What is a graph?

It's very simple. A graph consists fundamentally of two elements: nodes and vertices (or edges). The nodes represent states or entities, while the vertices connect (or not) these nodes. Graphs can be directed or undirected, which is then indicated with an arrow that begins at one node and ends at another.

It's surprising that this powerful concept remains relatively hidden in many technical degree curricula. Personally, thinking about a problem in terms of graphs has become one of my first approaches to any complex challenge. It's an incredibly valuable visual and conceptual tool that allows us to model situations in varied contexts.


Graphs are everywhere

Below I'll mention just a few examples of areas where we can analyze complex systems in terms of graphs:


1. Social networks

Perhaps the most intuitive example currently: in a social network, people are the nodes and connections (friendship, following, interaction) are the vertices. The analysis of these graphs allows everything from recommending new friendships to detecting communities or identifying influencers.


This graph represents a small social network where each node is a person and the edges (arrows) indicate "who follows whom." The relationships are directed, which means that if there's an arrow from Ana to Berto, Ana follows Berto, but not necessarily vice versa.
This graph represents a small social network where each node is a person and the edges (arrows) indicate "who follows whom." The relationships are directed, which means that if there's an arrow from Ana to Berto, Ana follows Berto, but not necessarily vice versa.

2. Logistics networks

Imagine a logistics network with several cities. Each city is a node, and the roads that connect them are the vertices. This visual representation immediately allows us to understand the structure of the network, identify optimal routes, or detect critical points whose elimination could disconnect parts of the network.


ree

In this example we find a logistics network where each node represents a major Spanish city and each edge represents a direct connection between cities. The graph is not directed because we assume that the connections allow traffic in both directions.

This representation allows us to quickly identify important aspects of the network such as:

  • Direct routes between cities

  • Critical points (if Madrid were isolated, the network would fragment significantly)

  • Better connected cities (Madrid has four connections, making it the main logistics hub of the country)


3. Financial markets

In the financial realm, it's also possible to make great use of graphs. A market graph can be formed by considering each financial asset as a node. The correlations between the returns of these assets will be the basis for constructing the vertices of the graph.

More rigorously, we can formulate this graph based on the Pearson correlation coefficient (r) between the returns or logarithmic returns of pairs of stocks. These correlations can take values between -1 and 1, indicating perfect negative or positive correlations, respectively.

To construct a very simple connection graph, we can apply a correlation threshold method (θ), where an edge will exist between nodes i and j if their corresponding correlation (r_ij) is greater than or equal to this threshold (r_ij ≥ θ).


ree

In this example, each node represents an important stock and each edge represents a significant correlation between price movements. It includes two clearly differentiated sectors: technology (Apple, Microsoft, Amazon, Google, Meta) and financial (JP Morgan, Bank of America, Goldman Sachs, Wells Fargo, Morgan Stanley).

A graph allows us to identify not only groups of stocks that tend to move together within the same sector, but also the limited connections between different sectors. We observe that Apple has a correlation with JP Morgan and Microsoft with Goldman Sachs, but in general there are few intersectoral connections, which suggests good diversification opportunities when investing in both sectors.


4. Linguistic analysis

Now let's explore a final example that is less obvious but equally fascinating. In the field of linguistic analysis, we can represent words as nodes in a graph. The vertices between these words can indicate different types of connections, such as:

  • That two words frequently appear together in a text (co-occurrence)

  • That one word tends to follow another in a text (sequence)

This approach allows us to do very interesting things. For example, we can use Markov chains to generate new text following the probability patterns of the connections between words. We can also analyze the characteristic stylistic structure of a particular author.

In fact, the resulting graph functions as a kind of linguistic "fingerprint," revealing unique patterns in vocabulary and phrase construction that are characteristic of each writer. This technique even allows us to identify the authorship of anonymous texts by comparing their linguistic graphs with those of known authors.


Why are there graphs everywhere?

Here's the insight: graphs encode relationships! And relationships are the very essence of our world. Nothing exists in isolation; everything is what it is only to the extent that it relates or doesn't relate to everything else. The concept of relationship is found at the irreducible basis of existence itself.

The particles that form our universe interact with each other following the dictates of the laws of physics. The elementary particles of the universe organize to give rise to atoms, molecules, cells, organic tissues, neurons, and finally a brain and a body that we use to understand that same order from which we come. If objects didn't relate to each other, the universe would be a strictly random place, and nothing interesting would happen in it.

Graphs don't appear in various contexts by accident. They appear because they are visual manifestations of our knowledge about relationships in a system. And they will continue to appear absolutely everywhere as long as we are able to concretize that type of knowledge. They are fundamental structures because they represent something equally fundamental: the interconnection of things!


Graphs and matrices: two sides of the same coin

And here we come to a fascinating revelation: a graph can be perfectly represented by a matrix (called an adjacency matrix), and vice versa. Each row and column of the matrix corresponds to a node, and the values indicate whether there is a connection between them and, if so, its weight or intensity.

So my teacher was right after all: everything is matrices and poetry. Or graphs and poetry, which amounts to the same thing. The mathematical structures that capture relationships (whether matrices or graphs) and the human capacity to find beauty and meaning in those connections.


What does all this have to do with quantum-inspired algorithms?

It turns out that there are several problems defined on graphs that are computationally complex. Detecting specific structures such as cliques (subsets of nodes where all are connected to each other) or independent sets (sets of nodes where none is connected to another in the same set) are problems classified as NP-Hard.

These combinatorial problems represent a formidable challenge for conventional algorithms, which frequently are forced to resort to approximations or heuristics when the size of the graph grows.

This is where quantum-inspired algorithms come into play, like the ones we develop at Inspiration-Q, specifically designed to address these complex combinatorial problems with greater efficiency. These algorithms can explore multiple solutions simultaneously and converge toward optimal or near-optimal solutions much more quickly. The best part is that we have packaged all this knowledge into an API platform called iQ-Xtreme, which you can use without having to worry about anything more than defining your graph as a matrix.


Want to know more?

Would you like to delve even deeper into the meaning of relationships, matrices and graphs? I recommend consulting chapters 1 and 7 of "Everything I Can Imagine: The Algorithm of Understanding".

Would you like to know more about graph optimization with quantum-inspired algorithms? Check out our website and contact us

 
 
 

Comments


bottom of page