<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Vlasta Pavicic</title>
    <description>The latest articles on Forem by Vlasta Pavicic (@vpavicic).</description>
    <link>https://forem.com/vpavicic</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1017351%2Fc745ef4b-b8d1-40eb-abe7-39ee60676e95.jpeg</url>
      <title>Forem: Vlasta Pavicic</title>
      <link>https://forem.com/vpavicic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vpavicic"/>
    <language>en</language>
    <item>
      <title>Memgraph vs. TigerGraph</title>
      <dc:creator>Vlasta Pavicic</dc:creator>
      <pubDate>Fri, 18 Aug 2023 06:43:44 +0000</pubDate>
      <link>https://forem.com/memgraph/memgraph-vs-tigergraph-405o</link>
      <guid>https://forem.com/memgraph/memgraph-vs-tigergraph-405o</guid>
      <description>&lt;p&gt;In today's data-driven world, the necessity to process and interpret complex relationships within massive datasets is making organizations continually search for the go-to graph database, leaving the traditional relational database options behind. After the initial &lt;a href="https://db-engines.com/en/ranking/graph+dbms"&gt;DB-Engines&lt;/a&gt; consultations, two names commonly arise in conversations: TigerGraph and Memgraph. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B5ldneKA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/tigergraph-vs-memgraph/db-rankings.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B5ldneKA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/tigergraph-vs-memgraph/db-rankings.png" alt="db-engines-ranks" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Background on both solutions
&lt;/h2&gt;

&lt;p&gt;Founded in 2012 by Dr. Yu Xu, &lt;strong&gt;TigerGraph's&lt;/strong&gt; core objective is to provide a scalable and efficient graph database platform that enables organizations to leverage the power of interconnected data, supporting applications ranging from fraud detection to AI and machine learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Memgraph&lt;/strong&gt; is an in-memory, open-source graph database with roots in the UK and Croatia. Founded by Marko Budiselic and Dominik Tomicevic in 2016, and backed by American investors, Memgraph prioritizes high performance and developer accessibility. With a robust community edition, the platform offers a blend of ease of use and practical functionality, all presented through clear and uncomplicated &lt;a href="https://memgraph.com/blog/what-is-an-open-source-license"&gt;licensing&lt;/a&gt;, making it the backbone of many cybersecurity solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Memgraph vs. TigerGraph differences
&lt;/h2&gt;

&lt;p&gt;Although both TigerGraph and Memgraph have been developed in C++ and aim to provide performant solutions for &lt;a href="https://memgraph.com/blog/real-time-graph-analytics"&gt;real-time data analytics&lt;/a&gt;, there exist some important differences between the two platforms that set them apart. Let’s check what those are.&lt;/p&gt;

&lt;h3&gt;
  
  
  Query language
&lt;/h3&gt;

&lt;p&gt;The choice of query language plays a significant role in the overall user experience.&lt;/p&gt;

&lt;p&gt;GSQL, TigerGraph's proprietary query language, does offer an expressive, Turing-complete language tailored for graph pattern-matching and analytics functions but might present a steeper learning curve for those new to graphs. It has been specifically designed for TigerGraph, and the skillset may not be easily transferred from or to other graph database platforms. &lt;/p&gt;

&lt;p&gt;In contrast, Cypher query language is an open-source, declarative language known for its user-friendly syntax. Cypher's human-readable style has propelled it into a standard for querying graph databases. It has been developed by Neo4j but is utilized by various systems, including Memgraph. Due to its simplicity, and broad community support, it is a preferred choice for many developers who know their applications will need minimum changes if they require a switch to another database vendor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data storage
&lt;/h3&gt;

&lt;p&gt;TigerGraph and Memgraph offer distinctive approaches to handling data in their graph databases, each reflecting a unique strategy to balance performance, scalability, and flexibility. &lt;/p&gt;

&lt;p&gt;TigerGraph employs a hybrid memory-disk approach, leveraging RAM for storing frequently accessed data and disk storage for large graphs that may exceed available memory. This hybrid model allows TigerGraph to achieve real-time analytics, where active datasets are immediately available, while also scaling to handle massive datasets without being constrained by RAM.&lt;/p&gt;

&lt;p&gt;In contrast, Memgraph's architecture has been built natively for in-memory data analysis and storage, focusing on lightning-fast data processing. Being ACID compliant, it ensures consistency and reliability in its core design. However, Memgraph also offers flexibility. An analytical storage mode that bypasses ACID compliance is available, accelerating analytics and data import operations when absolute consistency is not required. Additionally, an on-disk storage option allows users to weigh performance against budget constraints, thus achieving a balance tailored to specific needs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mTjPjUl_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/tigergraph-vs-memgraph/storage-modes.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mTjPjUl_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/tigergraph-vs-memgraph/storage-modes.png" alt="storage-modes" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While TigerGraph's hybrid approach offers a comprehensive solution for both speed and scalability, Memgraph's focus on in-memory processing with adaptable options reflects a commitment to performance with versatility to suit various requirements. The distinction between these two models shows the innovation in graph database technology, catering to diverse needs in data management, analysis, and storage. &lt;/p&gt;

&lt;h3&gt;
  
  
  Data isolation level
&lt;/h3&gt;

&lt;p&gt;TigerGraph employs a &lt;a href="https://memgraph.com/blog/acid-transactions-meaning-of-isolation-levels"&gt;read-committed data isolation level&lt;/a&gt;, meaning that a transaction can access data which is committed before and during this transaction’s execution.&lt;br&gt;
For example, two same READ queries inside one transaction can return different results because between them another transaction was committed.&lt;/p&gt;

&lt;p&gt;On the other hand, Memgraph uses snapshot isolation by default, where each query operates on a consistent snapshot of the data at the query's start time, with the option to change the isolation level, but snapshot isolation offers an advantage as it provides a more consistent view of the data, reducing the chance of reading partial or uncommitted changes. This ensures more accurate query results and a smoother transaction experience, making snapshot isolation generally considered a more reliable approach in many scenarios.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pricing models and support
&lt;/h3&gt;

&lt;p&gt;TigerGraph has a free version that allows users to work with up to 50GB of data, making it suitable for small projects or initial exploration. Memgraph offers something different with its &lt;a href="https://memgraph.com/pricing"&gt;Community Edition&lt;/a&gt;, which is not only free but also open-source and packed with features.&lt;/p&gt;

&lt;p&gt;For example, both TigerGraph and Memgraph offer high availability features to ensure that data is consistently accessible and resistant to failures, but Memgraph's replication is available even in the Community Edition of the product. This means that the Community Edition is not "crippleware" but a fully functional version that allows users to "kick the tires" on the product and properly test it to ensure it meets requirements before deploying it in a production environment.&lt;/p&gt;

&lt;p&gt;By offering this, and a plethora of other features in the Community Edition, Memgraph not only shows a commitment to performance and reliability but also to accessibility, empowering users to explore and validate the capabilities of the software without barriers.&lt;/p&gt;

&lt;p&gt;Due to the lack of complicated layers of management that some larger companies might have, in Memgraph you can talk directly to engineers if you have questions or need help. It's a more hands-on, direct way of working that puts you closer to the people who built the product, and it can make working with Memgraph a more pleasant and efficient experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Overview of features
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vm3EHAvR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/memgraph-vs-tigergraph/overview-of-features.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vm3EHAvR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/memgraph-vs-tigergraph/overview-of-features.png" alt="overvies-of-features" width="743" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways on both graph databases
&lt;/h2&gt;

&lt;p&gt;Memgraph and TigerGraph both offer graph database solutions, but Memgraph's native in-memory design sets it apart. Built for speed without losing stability or ACID compliances, Memgraph provides efficient real-time querying and analytics. Although TigerGraph claims to be "The World’s Fastest Graph Analytics Platform for the Enterprise", clients have reported increased performance after switching to Memgraph. If speed, reliability, direct interaction, and support from engineers are key priorities, Memgraph may be the more appealing choice. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ePlK0GrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/tigergraph-vs-memgraph/benchgraph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ePlK0GrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/tigergraph-vs-memgraph/benchgraph.png" alt="benchgraph" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check the performance of Memgraph on your own dataset using &lt;a href="https://memgraph.com/blog/benchmark-memgraph-or-neo4j-with-benchgraph"&gt;Benchgraph&lt;/a&gt;, a graph database performance benchmark, and feel free to &lt;a href="https://memgraph.com/contact-us"&gt;contact us&lt;/a&gt; about making the switch.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Graph Search Algorithms: Developer's Guide</title>
      <dc:creator>Vlasta Pavicic</dc:creator>
      <pubDate>Thu, 15 Jun 2023 14:32:38 +0000</pubDate>
      <link>https://forem.com/memgraph/graph-search-algorithms-developers-guide-k6m</link>
      <guid>https://forem.com/memgraph/graph-search-algorithms-developers-guide-k6m</guid>
      <description>&lt;p&gt;Graph search algorithms form the backbone of many applications, from social network analysis and route planning to data mining and recommendation systems. In this developer's guide, we will delve into the world of graph search algorithms, exploring their definition, significance, and practical applications.&lt;/p&gt;

&lt;p&gt;At its core, a graph search algorithm is a technique used to traverse a graph, which is a collection of nodes connected by relationships. In various domains such as social networks, web pages, or biological networks, graph theory offers a powerful way to model complex interconnections.&lt;/p&gt;

&lt;p&gt;The significance of graph search algorithms lies in their ability to efficiently explore and navigate these intricate networks. By traversing the graph, these algorithms can uncover hidden patterns, discover the shortest paths, and identify clusters.&lt;/p&gt;

&lt;p&gt;One of the primary benefits of graph search algorithms is their adaptability to a wide array of applications. Whether you're developing a social media platform, designing a logistics system, or &lt;a href="https://memgraph.com/blog/building-a-recommendation-system-using-memgraph"&gt;building a recommendation engine&lt;/a&gt;, by understanding the foundations of graph search algorithms and learning how to leverage them effectively, you'll unlock new possibilities for solving complex problems and advancing your development skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of graphs
&lt;/h2&gt;

&lt;p&gt;Graphs are versatile data structures that can represent various types of relationships between objects. Understanding the different types of graphs is essential for effectively applying graph search algorithms. In this chapter, we will explore the most common types of graphs, their characteristics, and applications, along with visual examples to aid comprehension.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Directed graphs&lt;/strong&gt;, also known as a digraph, consist of nodes connected by directed relationships. In a directed relationship, there is a specific direction from one node (the source) to another node (the target). A directed graph is used to model relationships with a sense of direction, such as web pages with hyperlinks, dependencies between tasks, or social media following relationships.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Undirected graph&lt;/strong&gt; is a graph in which relationships have no specified direction. Undirected graphs are commonly used to represent relationships that are bidirectional, such as friendships in a social network or connections between web pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weighted graphs&lt;/strong&gt; assign numerical values, known as weights, to relationships to represent the strength, distance, or cost between nodes. These weights can influence the behavior of graph search algorithms, allowing for more specific optimizations or finding the shortest or cheapest paths. Weighted graphs find applications in areas like network routing, resource allocation, or finding optimal solutions in various domains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bipartite graph&lt;/strong&gt; is a graph whose nodes can be divided into two disjoint sets, and all relationships connect nodes from different sets. Bipartite graphs are often used to model relationships between two distinct types of entities, such as users and products, students and courses, or employees and skills. They are particularly useful in applications like recommendation systems or matching problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cyclic graphs&lt;/strong&gt; contain at least one cycle, which is a path that starts and ends at the same node. &lt;strong&gt;Acyclic graphs&lt;/strong&gt;, as the name suggests, do not contain any cycles. Cyclic graphs can represent scenarios with repeating or circular relationships, while acyclic graphs are often used in tasks like topological sorting or modeling hierarchical structures.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2St1_RmL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/types-of-graphs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2St1_RmL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/types-of-graphs.png" alt="types of graphs" width="800" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Understanding the different types of graphs provides developers with a foundation for choosing the appropriate graph representation for their specific problem. Each type has its own characteristics and applications, and selecting the right graph structure can significantly impact the efficiency and accuracy of graph search algorithms.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic graph search algorithms 
&lt;/h2&gt;

&lt;p&gt;In the realm of graph search algorithms, two fundamental techniques stand out: &lt;a href="https://memgraph.com/docs/memgraph/reference-guide/built-in-graph-algorithms#breadth-first-search"&gt;Breadth-first search (BFS)&lt;/a&gt; and &lt;a href="https://memgraph.com/docs/memgraph/reference-guide/built-in-graph-algorithms#depth-first-search"&gt;Depth-first search (DFS)&lt;/a&gt;. These algorithms provide crucial building blocks for traversing and exploring graphs in different ways. While BFS focuses on exploring the breadth of a graph by systematically visiting all neighboring nodes before moving deeper, DFS delves into the depths of a graph, exhaustively exploring one branch before backtracking. &lt;/p&gt;

&lt;h3&gt;
  
  
  BFS and DFS Basics
&lt;/h3&gt;

&lt;p&gt;Depth-first search is an algorithm that explores a graph by traversing as far as possible along each branch before backtracking. The key working principle of DFS is to visit a node and then recursively explore its unvisited neighbors until there are no more unvisited nodes in that branch. This depth-first exploration strategy can be implemented using a stack or recursion. By utilizing a stack, DFS ensures that the most recently discovered nodes are visited first, delving deeper into the graph.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p5YBF3Xx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/bfs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p5YBF3Xx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/bfs.gif" alt="bfs" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Breadth-first search or the BFS algorithm systematically explores a graph by visiting all the neighboring nodes of a given level before moving to the next level. The core working principle of BFS is to use a queue to maintain a level-wise exploration order. Initially, the algorithm starts with a source node, enqueues its neighbors, and continues this process until all nodes have been visited. The breadth-first traversal strategy ensures that nodes are visited in increasing order of their distance from the source, allowing for finding the shortest path in unweighted graphs.&lt;/p&gt;

&lt;p&gt;Both DFS and BFS maintain a record of visited nodes to prevent revisiting the same node repeatedly. This visited node management is crucial to ensure that the algorithms terminate correctly and avoid infinite loops in cyclic graphs. Typically, a boolean array or hash set is used to keep track of visited nodes, marking them as visited when they are encountered during graph traversal.&lt;/p&gt;

&lt;p&gt;In terms of time and space complexities, the time complexity of both algorithms is &lt;em&gt;O(V + E)&lt;/em&gt;, where &lt;em&gt;V&lt;/em&gt; represents the number of vertices (nodes) and &lt;em&gt;E&lt;/em&gt; represents the number of edges (relationships) in the graph. The space complexity for both algorithms is &lt;em&gt;O(V)&lt;/em&gt; since DFS requires a stack to keep track of nodes, while BFS requires a queue to store nodes during traversal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use cases 
&lt;/h3&gt;

&lt;p&gt;DFS and BFS are powerful graph search algorithms that find wide-ranging applications across various domains. &lt;/p&gt;

&lt;p&gt;BFS is often employed in &lt;strong&gt;web crawling&lt;/strong&gt;, where it helps in systematically exploring and indexing web pages starting from a given source page. By utilizing BFS, web crawlers can visit neighboring pages before moving to deeper levels, ensuring comprehensive coverage of a website or a set of interconnected websites. BFS-based crawling allows search engines to index web pages efficiently, enabling users to find relevant information quickly.&lt;/p&gt;

&lt;p&gt;BFS plays a vital role in &lt;a href="https://memgraph.com/blog/diving-into-the-vehicle-routing-problem"&gt;route planning&lt;/a&gt; algorithms, especially in unweighted graphs or maps. It helps in finding the shortest path between two locations, ensuring that the traversal explores neighboring locations before expanding the search to farther areas. By utilizing BFS, route planning applications can provide optimal directions, whether it's for driving, walking, or public transportation.&lt;/p&gt;

&lt;p&gt;DFS and BFS are valuable tools in &lt;a href="https://memgraph.com/recommendation-engine"&gt;recommendation engines&lt;/a&gt;, helping to discover relevant content or items for users. DFS can be used to find similar users or items based on shared characteristics, facilitating collaborative filtering approaches. BFS can explore the graph of user-item interactions to recommend items that are highly connected or related to the user's preferences.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;social networks&lt;/strong&gt; DFS can be used to identify connected components, finding groups of individuals who are mutually connected. BFS is useful for determining the shortest path between two individuals, showcasing the most efficient connections within the network. These algorithms also aid in social network analysis, such as identifying influential individuals or detecting communities and clusters.&lt;/p&gt;

&lt;p&gt;The applications mentioned above provide just a glimpse into the broad spectrum of possibilities that DFS and BFS offer. These algorithms are versatile tools that can be adapted to various domains and problem spaces, allowing developers to tackle complex challenges efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;Implementing DFS and BFS requires careful consideration and adherence to best practices to ensure correct and efficient implementations.&lt;/p&gt;

&lt;p&gt;As a first step, understand the implications of DFS and BFS traversal orders and select the appropriate order for your specific use case. &lt;/p&gt;

&lt;p&gt;For DFS, decide whether to explore the graph in a pre-order, in-order, or post-order manner. In pre-order DFS, a node is processed (visited or printed) before traversing its children. The traversal starts at the root node and then recursively explores the left and right subtrees in pre-order. The pre-order strategy is often used in tree-based traversals.&lt;/p&gt;

&lt;p&gt;In in-order DFS, a node is processed between the traversal of its left and right subtrees. In other words, the left subtree is explored first, followed by processing the current node and then exploring the right subtree. In-order DFS is primarily used in binary tree traversals and is especially relevant for binary search trees to visit nodes in ascending order. In post-order DFS, a node is processed after traversing its children.&lt;/p&gt;

&lt;p&gt;The traversal starts at the root node and recursively explores the left and right subtrees in post-order before finally processing the current node. Post-order DFS is commonly used in tree-based algorithms that require processing child nodes before processing the parent node.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0ppCu4dq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/binary-tree.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0ppCu4dq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/binary-tree.png" alt="binary tree" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pre-order is often useful for constructing a copy of the tree or encoding the tree structure. In-order is suitable for tasks like sorting elements in a binary search tree. Post-order is valuable for tasks such as calculating expressions in a parse tree.&lt;/p&gt;

&lt;p&gt;For BFS, ensure that the traversal explores nodes in the order dictated by the queue, maintaining the level-wise exploration.&lt;/p&gt;

&lt;p&gt;If the graph contains cycles, consider incorporating cycle detection mechanisms or break conditions to avoid infinite loops during traversal. Implement a mechanism to handle backtracking in DFS to ensure that previously visited nodes are not revisited unnecessarily.&lt;/p&gt;

&lt;p&gt;Be aware of the time and space complexities of DFS and BFS to gauge their efficiency and performance for different graph sizes and structures.&lt;/p&gt;

&lt;p&gt;Consider the following pseudocode examples for implementing DFS and BFS.&lt;/p&gt;

&lt;p&gt;Depth-First Search (DFS):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function dfs(graph, start):

    stack.push(start)

    visited[start] = true


    while stack is not empty:

        current = stack.pop()

        process(current)


        for each neighbor in graph.adjacentNodes(current):

            if neighbor is not visited:

                stack.push(neighbor)

                visited[neighbor] = true

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;BFS (Breadth-First Search):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function bfs(graph, start):

    queue.enqueue(start)

    visited[start] = true


    while queue is not empty:

        current = queue.dequeue()

        process(current)


        for each neighbor in graph.adjacentNodes(current):

            if neighbor is not visited:

                queue.enqueue(neighbor)

                visited[neighbor] = true

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced graph search algorithm 
&lt;/h2&gt;

&lt;p&gt;In addition to the basic graph search algorithms DFS and BFS, advanced graph search algorithms offer powerful solutions to more complex problems. Two such algorithms, Dijkstra's and Bellman-Ford algorithms, play a crucial role in finding the shortest paths in weighted graphs. In this section, we will introduce Dijkstra's Algorithm and Bellman-Ford Algorithm, highlighting their significance in optimizing route planning, network routing, and other applications that involve finding the most efficient paths in graphs with weighted edges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dijkstra's and Bellman-Ford basics
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://memgraph.com/docs/memgraph/reference-guide/built-in-graph-algorithms#weighted-shortest-path"&gt;Dijkstra's algorithm&lt;/a&gt; is a widely used algorithm for finding the shortest path between a source node and all other nodes in a weighted graph. It works on graphs with non-negative relationship weights and is particularly suitable for scenarios like route planning, network routing, or finding optimal paths in transportation networks.&lt;/p&gt;

&lt;p&gt;Dijkstra's algorithm employs a greedy approach, iteratively selecting the node with the smallest tentative distance and updating the distances of its neighboring nodes until all nodes have been visited. It maintains a priority queue or a min-heap to efficiently extract the node with the minimum distance. It has a time complexity of &lt;em&gt;O(V^2)&lt;/em&gt; using the adjacency matrix representation of the graph. The time complexity can be reduced to &lt;em&gt;O((V+E)logV)&lt;/em&gt; using an adjacency list representation of the graph, where &lt;em&gt;E&lt;/em&gt; is the number of edges (relationships) in the graph and V is the number of vertices (nodes) in the graph.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e2GlsoXY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/dijkstra.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e2GlsoXY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/dijkstra.gif" alt="dijkstra" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bellman-Ford is another important algorithm for finding the shortest paths in graphs that may contain negative relationship weights. Unlike Dijkstra's algorithm, which assumes non-negative weights, the Bellman-Ford algorithm can handle graphs with negative weights as long as there are no negative cycles. It is commonly used in scenarios such as network routing, distance vector routing protocols, or detecting negative cycles in graphs. The Bellman-Ford algorithm iterates through all relationships in the graph repeatedly, updating the distances of nodes based on the relaxation principle. It maintains an array to track the distances of nodes and iterates through all relationships &lt;em&gt;|V| - 1&lt;/em&gt; times to ensure convergence. The time complexity of the Bellman-Ford algorithm is &lt;em&gt;O(V E)&lt;/em&gt;, where &lt;em&gt;V&lt;/em&gt; represents the number of vertices and &lt;em&gt;E&lt;/em&gt; represents the number of relationships in the graph.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cFx_1MAu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/bellman-ford.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cFx_1MAu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://public-assets.memgraph.com/graph-search-algorithms-developers-guide/bellman-ford.gif" alt="bellman ford" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Use cases 
&lt;/h3&gt;

&lt;p&gt;Dijkstra's and Bellman-Ford algorithms excel in solving real-world problems related to route planning, network optimization, resource allocation, and various other domains.&lt;/p&gt;

&lt;p&gt;Both algorithms are extensively used in &lt;a href="https://memgraph.com/blog/how-to-build-a-route-planning-application-with-breadth-first-search-and-dijkstras-algorithm"&gt;route planning&lt;/a&gt; applications to find the shortest path between locations in transportation networks, such as roads, railways, or flight routes. These algorithms enable navigation systems to calculate optimal routes for drivers, public transportation, and logistics planning.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;computer networks&lt;/strong&gt;, these graph search algorithms play a crucial role in determining the most efficient paths for routing packets or establishing network connections. They help optimize the flow of data, reduce latency, and improve network performance. Dijkstra's Algorithm is commonly used in link-state routing protocols like OSPF (Open Shortest Path First), while the Bellman-Ford algorithm is employed in distance-vector routing protocols like RIP (Routing Information Protocol).&lt;/p&gt;

&lt;p&gt;Both Dijkstra's algorithm and Bellman-Ford algorithm find applications in resource allocation problems, such as &lt;strong&gt;allocating resources&lt;/strong&gt; in cloud computing, &lt;strong&gt;scheduling tasks&lt;/strong&gt;, or &lt;strong&gt;optimizing supply chains&lt;/strong&gt;. These algorithms assist in identifying the most cost-effective or time-efficient paths to allocate resources and optimize resource utilization. The Bellman-Ford algorithm is especially useful with negative relationship weights (without negative cycles) in scenarios where resource costs or constraints are involved.&lt;/p&gt;

&lt;p&gt;The algorithms also aid in &lt;a href="https://memgraph.com/energy-management-system"&gt;managing critical infrastructure and facilities&lt;/a&gt;, such as &lt;a href="https://memgraph.com/blog/solving-most-common-problems-in-energy-management-systems-solved-with-graph-analytics"&gt;power grids&lt;/a&gt;, telecommunications networks, or water distribution systems where they can identifying optimal paths for maintenance crews, detecting faults or disruptions, and optimizing resource allocation for efficient operation.&lt;/p&gt;

&lt;p&gt;They can also help &lt;a href="https://memgraph.com/network-resource-optimization"&gt;optimize supply chain and logistics operations&lt;/a&gt;, such as inventory management, order fulfillment, or delivery route optimization by determining the most efficient paths for transporting goods, minimizing costs, and improving customer satisfaction.&lt;/p&gt;

&lt;p&gt;The applications mentioned above are just a glimpse of the diverse possibilities that Dijkstra's and Bellman-Ford algorithms offer. Both are versatile and can be adapted to various problem domains requiring optimization and efficient path-finding in graphs. &lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;When implementing graph search algorithms, such as Dijkstra's algorithm and Bellman-Ford algorithm, be sure to provide proper handling of relationship weights according to the requirements of the algorithms. &lt;/p&gt;

&lt;p&gt;In the case of using Dijkstra's algorithm, validate that the relationship weights are non-negative. For the Bellman-Ford algorithm, ensure that the graph does not contain any negative cycles to maintain correct behavior.&lt;/p&gt;

&lt;p&gt;Initialize data structures and variables appropriately before starting the algorithm. Set initial distances to infinity for Dijkstra's algorithm and initialize distances to 0 for the source node in the Bellman-Ford algorithm. Initialize other auxiliary data structures as required, such as priority queues or arrays.&lt;/p&gt;

&lt;p&gt;Understand the relaxation step in each algorithm and implement it correctly. Update the distances and other relevant information whenever a shorter path is found during the traversal.&lt;/p&gt;

&lt;p&gt;Implement appropriate termination conditions for the algorithms to ensure they terminate correctly. For Dijkstra's algorithm, terminate when the destination node is reached or when all reachable nodes have been visited. In the Bellman-Ford algorithm, terminate when no further updates can be made, indicating that the distances have converged.&lt;/p&gt;

&lt;p&gt;Consider the following &lt;a href="https://memgraph.com/blog/graph-algorithms-cheat-sheet-for-coding-interviews"&gt;pseudocode examples&lt;/a&gt; for implementing Dijkstra's and Bellman-Ford algorithms. The pseudocode assumes the existence of appropriate data structures like priorityQueue for Dijkstra's Algorithm and arrays like distances and visited to store necessary information.&lt;/p&gt;

&lt;p&gt;Dijkstra's algorithm:&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function dijkstra(graph, start):

    distances[start] = 0

    priorityQueue.enqueue(start, 0)


    while priorityQueue is not empty:

        current = priorityQueue.dequeue()

        visited[current] = true


        for each neighbor in graph.adjacentNodes(current):

            if not visited[neighbor]:

                distance = distances[current] + graph.edgeWeight(current, neighbor)

                if distance &amp;lt; distances[neighbor]:

                    distances[neighbor] = distance

                    priorityQueue.enqueue(neighbor, distance)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Bellman-Ford algorithm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function bellmanFord(graph, start):

    distances[start] = 0


    for i = 1 to |V| - 1:

        for each edge in graph.edges:

            source = edge.source

            destination = edge.destination

            weight = edge.weight


            if distances[source] + weight &amp;lt; distances[destination]:

                distances[destination] = distances[source] + weight


    for each edge in graph.edges:

        source = edge.source

        destination = edge.destination

        weight = edge.weight


        if distances[source] + weight &amp;lt; distances[destination]:

            // Negative cycle detected

            // Handle the presence of negative cycles accordingly

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Performance analysis and optimization 
&lt;/h2&gt;

&lt;p&gt;Efficient performance is crucial when working with graph search algorithms to tackle real-world problems effectively. The increase in the number of nodes and relationships in the graph and the higher density of the graph affect the algorithm's performance.&lt;/p&gt;

&lt;p&gt;Efficiency can be increased by incorporating domain-specific knowledge or rules, thus heuristically guiding the search process towards more promising paths and prioritizing nodes or edges, improving efficiency. Another way is by pruning, or eliminating branches or subtrees from further exploration based on certain criteria. Pruning techniques, such as alpha-beta pruning in game-playing scenarios, discard portions of the search space that are deemed irrelevant, significantly reducing the algorithm's runtime. Another technique is memoization, which involves storing previously computed results to avoid redundant calculations. In graph search algorithms, memoization can cache intermediate results, such as computed distances or paths, to avoid re-computation, especially when there are overlapping subproblems.&lt;/p&gt;

&lt;p&gt;BFS and DFS can benefit from performance optimizations by applying pruning techniques to skip unnecessary relationships or paths during traversal. Additionally, using appropriate data structures for maintaining visited nodes and tracking the traversal order can improve efficiency.&lt;/p&gt;

&lt;p&gt;The performance of Dijkstra's algorithm can be optimized by utilizing efficient data structures like priority queues or heaps to retrieve nodes with the minimum distance more quickly. Heuristics can also be incorporated to prioritize the exploration of nodes that are more likely to yield shorter paths.&lt;/p&gt;

&lt;p&gt;The Bellman-Ford algorithm can benefit from early termination if no updates are made during an iteration, indicating that the distances have converged. This can save unnecessary iterations, improving runtime.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;In this comprehensive guide, we have explored the fundamental concepts and practical applications of various graph search algorithms. Starting with the basic algorithms like BFS and DFS, we gained insights into their working principles and traversal strategies. We also delved into Dijkstra's and Bellman-Ford algorithms, which excel in solving complex problems involving weighted graphs. We explored their specific use cases, advantages over basic algorithms, and discussed optimization techniques to improve their efficiency.&lt;/p&gt;

&lt;p&gt;Understanding the nuances of graph search algorithms empowers the developer community to solve a wide range of problems across diverse domains, ultimately contributing to the advancement of technology and society.&lt;/p&gt;

&lt;p&gt;If you want to know more about various graph algorithms, download the &lt;a href="https://memgraph.com/white-paper/beginners-guide-to-graph-algorithms"&gt;Graph Algorithms for Beginners&lt;/a&gt; whitepaper that also deals with centrality and machine learning algorithms. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why are nodes with a high betweenness centrality score high maintenance</title>
      <dc:creator>Vlasta Pavicic</dc:creator>
      <pubDate>Thu, 16 Feb 2023 10:52:15 +0000</pubDate>
      <link>https://forem.com/memgraph/why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance-3m65</link>
      <guid>https://forem.com/memgraph/why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance-3m65</guid>
      <description>&lt;p&gt;Each process or network has very important resources you need to take extra care of - whether it’s that crucial piece of data, the unicorn dev you hired, or an expensive piece of infrastructure. Consequently, every graph dataset has very important nodes. Some nodes are important in the way they are crucial to the successful performance of your system, but some (sometimes those exact same) nodes are important because if they fail, they can wreak havoc.&lt;/p&gt;

&lt;p&gt;To find out which nodes in a network are important based on the topological structure of the network and thus relevant to its success or ruin, run a centrality analysis of the nodes in your graph database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Centrality analysis measures
&lt;/h2&gt;

&lt;p&gt;Centrality analysis can be done using measures that examine node &lt;strong&gt;degrees&lt;/strong&gt; or &lt;strong&gt;short paths&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A degree is the number of relationships a certain node has. When only the relationships of a specific node are important, the analysis is done using &lt;strong&gt;&lt;a href="https://memgraph.com/docs/mage/query-modules/cpp/degree-centrality" rel="noopener noreferrer"&gt;degree centrality&lt;/a&gt;&lt;/strong&gt;. But, if the degree of surrounding nodes is also included in the equation, the analysis is done using the &lt;strong&gt;eigenvector centrality&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Just like in real life, sometimes it’s important to have a lot of friends, but other times it’s important to have friends who have many other friends (politicians have cracked this one).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwulsa77vradkoqhv0igp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwulsa77vradkoqhv0igp.png" alt="why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The other way of looking at the importance of a node is by examining the number of shortest paths a node is a part of. To find out which node spreads the information the quickest because it’s the closest one to many other nodes, analyze the graph using the &lt;strong&gt;closeness centrality&lt;/strong&gt; (and find that one person that’s friends with everybody else and knows everything). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8ametgni0tl68483v5w.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8ametgni0tl68483v5w.gif" alt="why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance" width="798" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the graph above, both C and E nodes have high closeness centrality as they can access all other nodes the fastest.&lt;/p&gt;

&lt;p&gt;To identify the nodes that control the passing of information, you need to find out the nodes’ &lt;strong&gt;&lt;a href="https://memgraph.com/docs/mage/query-modules/cpp/betweenness-centrality" rel="noopener noreferrer"&gt;betweenness centrality&lt;/a&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Except for torturing you with spelling, betweenness centrality discovers nodes that have considerable influence over the network as they play the bridging role. Betweenness centrality is defined as the number of shortest paths that pass through the node divided by the total number of shortest paths between all pairs of nodes.&lt;/p&gt;

&lt;p&gt;It’s the person who brings many different people together. But when that bridging person is out of town, some of their friends are left spending the night alone in front of the TV. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfdnaiv8t22ez3qtpzdj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfdnaiv8t22ez3qtpzdj.gif" alt="why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance" width="797" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the graph above, node E is the node with the highest betweenness centrality score because if it became unoperational, it would disconnect the highest number of nodes from the rest of the graph.&lt;/p&gt;

&lt;p&gt;In other words, the moment the node with the high centrality betweenness score in any way fails to perform whatever it was designed to do, it’s time for fixing issues because some nodes are no longer attached to the network. So let’s look at betweenness centrality more closely to learn how to avoid problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Betweenness centrality use cases
&lt;/h2&gt;

&lt;p&gt;Betweenness centrality can help discover pain points in networks and &lt;a href="https://memgraph.com/knowledge-graph" rel="noopener noreferrer"&gt;knowledge graphs&lt;/a&gt; built around various industries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Network Optimization
&lt;/h3&gt;

&lt;p&gt;Maybe the most important usage of this algorithm is transportation. In a complex and urban transportation network, betweenness centrality measures can reveal the main bottlenecks and congestions within the system. It can help organize the infrastructure of a big city and decrease time spent optimizing routes.&lt;/p&gt;

&lt;p&gt;It can also be used to &lt;a href="https://memgraph.com/blog/analyze-infrastructure-networks-with-dynamic-betweenness-centrality" rel="noopener noreferrer"&gt;identify the most relevant landing points&lt;/a&gt; of the global network of submarine internet cables. Keeping a close eye on the cables between those points can avoid havoc if sharks attack and damage the cables… &lt;a href="https://www.forbes.com/sites/melissacristinamarquez/2020/07/20/our-underwater-world-is-full-of-cables-that-are-sometimes-attacked-by-sharks/?sh=29728c9060d2" rel="noopener noreferrer"&gt;again&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feh00cqwhtetmsj7xqa6f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feh00cqwhtetmsj7xqa6f.png" alt="why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenancet" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://memgraph.com/energy-management-system" rel="noopener noreferrer"&gt;energy management systems&lt;/a&gt;, betweenness centrality is an excellent indicator of weak points that could help prevent power outages between two distinct areas in the country or analyze critical points in the supply chain pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhl5sk01zkognb1oopnqw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhl5sk01zkognb1oopnqw.png" alt="why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Lineage
&lt;/h3&gt;

&lt;p&gt;In the &lt;a href="https://memgraph.com/data-lineage" rel="noopener noreferrer"&gt;data lineage&lt;/a&gt; graph, the betweenness centrality algorithm will identify nodes that are the main sources of data for other assets. Any mistakes found in those origin assets could impact the reliability of all the other connected data nodes. &lt;/p&gt;

&lt;p&gt;Also, nodes with high betweenness centrality scores can have a large number of data sources, making them susceptible to frequent changes which propagate to other data entities. It would be wise to check the reliability of those nodes often to make sure they source their data correctly. &lt;/p&gt;

&lt;h3&gt;
  
  
  Fraud Detection
&lt;/h3&gt;

&lt;p&gt;When analyzing a known &lt;a href="https://memgraph.com/fraud-detection-insurance" rel="noopener noreferrer"&gt;fraud&lt;/a&gt; organization, betweenness centrality helps identify nodes that act as bridges between clients as they are more likely to commit fraud. Once suspicions are confirmed, data can be fed to the &lt;a href="https://memgraph.com/blog/why-should-you-combine-machine-learning-and-graph-tech-to-build-your-fraud-detection-system" rel="noopener noreferrer"&gt;machine learning model&lt;/a&gt; to identify suspicious behaviors and clusters on larger datasets or predict fraud. &lt;/p&gt;

&lt;p&gt;While on the topic of fraud, lots of information, goods, and activities flow through the important nodes in a criminal network, especially through those with high betweenness centrality measures. These nodes could be particularly interesting to disrupt. Identifying and stopping the most effective fraudster could slow down the activity of the entire criminal network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Identity and Access Management
&lt;/h3&gt;

&lt;p&gt;The betweenness centrality measure can pinpoint which resources are controlled by a limited number of individuals. Access limited through only a few key persons might slow down the flow of information if some of those resources or people become unavailable. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5qhewh3zl5pca6zdlq0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5qhewh3zl5pca6zdlq0.png" alt="why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The worst-case scenario is if the flow is stopped completely. Just as PageRank can warn about excessive privileges in &lt;a href="https://memgraph.com/identity-access-management" rel="noopener noreferrer"&gt;identity and access management systems&lt;/a&gt;, betweenness centrality can alert about inadequate privileges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cyber security
&lt;/h3&gt;

&lt;p&gt;Some cyber-attacks aim to remove the most important node in the network topology, detaching its adjacent relationships and thus creating the most damage. By calculating the importance of the nodes in the network, you can direct your efforts to the most important parts of your infrastructure. &lt;/p&gt;

&lt;p&gt;Also, as a cyberattack is a series of actions that are carried out in a certain order (path) against  certain assets in the network (nodes), you can calculate through which node the most possible attack paths go. If each hop in the attack path is given a probability measure, you can use the graph as a vulnerability tree to predict which attacks are most likely to succeed. And come up with a plan to prevent them. &lt;/p&gt;

&lt;h3&gt;
  
  
  Recommendation Engines
&lt;/h3&gt;

&lt;p&gt;This is sort of a bonus use case, as it’s more targeted towards you succeeding rather than avoiding issues. If you are struggling with &lt;a href="https://memgraph.com/recommendation-engine" rel="noopener noreferrer"&gt;what products to recommend&lt;/a&gt;, think of the shopping process as a path of several crucial steps for your business (adding to basket, paying and similar actions) and steps that are mostly browsing and checking stuff out. &lt;/p&gt;

&lt;p&gt;The high betweenness centrality measure indicates that people bought certain items without too much wandering and overthinking - they saw it, added it to the basket, checkout and paid. The performed the shortest buying path and their paths might cross on a single product. Those are the products you should recommend as the must-haves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation in Memgraph
&lt;/h2&gt;

&lt;p&gt;The calculation of betweenness centrality is not standardized, and there are many ways to solve it.  The algorithm implemented in Memgraph is described in the paper "A Faster Algorithm for Betweenness Centrality" by Ulrik Brandes of the University of Konstanz. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://memgraph.com/docs/mage/query-modules/cpp/betweenness-centrality" rel="noopener noreferrer"&gt;Memgraph has implemented betweenness centrality using C++&lt;/a&gt;, which makes it ideal for use cases where performance is highly valuable. The graph can be both directed and undirected, and the algorithm doesn’t take relationships' weight into account. &lt;/p&gt;

&lt;p&gt;Default arguments are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;directed: boolean (default=True)&lt;/code&gt; ➡ If &lt;code&gt;False&lt;/code&gt;, the direction of relationships is ignored.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;normalized: boolean (default=True)&lt;/code&gt; ➡  If &lt;code&gt;True&lt;/code&gt;, the betweenness values are normalized by &lt;code&gt;2/((n-1)(n-2))&lt;/code&gt; for graphs, and &lt;code&gt;1/((n-1)(n-2))&lt;/code&gt; for directed graphs where n is the number of nodes.
*

&lt;code&gt;threads: integer (default=number of concurrent threads supported by the implementation)&lt;/code&gt;

➡ The number of threads used to calculate betweenness centrality.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The function returns the node and its betweenness centrality measure. &lt;/p&gt;

&lt;p&gt;To call betweenness centrality in Memgraph, use the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality.get&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt; 
&lt;span class="k"&gt;YIELD&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality&lt;/span&gt; 
&lt;span class="k"&gt;RETURN&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality&lt;/span&gt;&lt;span class="ss"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can try it out on Playground, in the Sandbox of the &lt;a href="https://playground.memgraph.com/sandbox/protein-interactions" rel="noopener noreferrer"&gt;Protein-protein interaction network&lt;/a&gt; dataset. Proteins found in human tissue actually make an &lt;a href="https://memgraph.com/blog/identifying-essential-proteins-betweenness-centrality" rel="noopener noreferrer"&gt;interaction network&lt;/a&gt;. By calculating the betweenness centrality of proteins, it was found that there is a correlation between the APP protein and Alzheimer’s disease, which could be interpreted as a connection between essential proteins and diseases in general.&lt;/p&gt;

&lt;p&gt;Check the protein with the highest betweenness centrality measure that could be connected to certain diseases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality.get&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt; 
&lt;span class="k"&gt;YIELD&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality&lt;/span&gt; 
&lt;span class="k"&gt;RETURN&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="ss"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl28laxno6no9wiyz3xib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl28laxno6no9wiyz3xib.png" alt="why-are-nodes-with-a-high-betweenness-centrality-score-high-maintenance" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As with all the other algorithms in the MAGE open-source library, you can run betweenness centrality only on a specific group of nodes with the &lt;a href="https://memgraph.com/docs/mage/how-to-guides/run-a-subgraph-module" rel="noopener noreferrer"&gt;&lt;code&gt;project()&lt;/code&gt; function&lt;/a&gt;. Save the sub-graph in a variable, then provide it as a first argument of the algorithm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;MATCH&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="py"&gt;n:&lt;/span&gt;&lt;span class="n"&gt;SpecificLabel&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;subgraph&lt;/span&gt;
&lt;span class="k"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;betweenness_centrality.get&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subgraph&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;YIELD&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;RETURN&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="ss"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your application is highly time-sensitive and nodes and relationships are arriving in a short period of time, use the &lt;a href="https://memgraph.com/docs/mage/query-modules/cpp/betweenness-centrality-online" rel="noopener noreferrer"&gt;dynamic betweenness centrality&lt;/a&gt; which allows the preservation of the previously processed state. When entities are updated, or new ones arrive in the graph, instead of restarting the algorithm over the whole graph, only the neighborhood objects of that arriving entity are processed at a constant time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Betweenness centrality will help you identify nodes that are ticking time bombs. If they fail, your network could be in trouble, as the flow between all nodes in the graph will be stopped until you come up with a fix. Keep the betweenness centrality of your nodes low, and if there is no other choice, take extra special care of them. &lt;/p&gt;

&lt;p&gt;If you need help identifying those weak points, a welcoming community at &lt;a href="https://discord.com/invite/memgraph" rel="noopener noreferrer"&gt;Memgraph’s Discord server&lt;/a&gt; will be more than happy to help you integrate graphs and algorithms into your system. We all want you to succeed! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://memgraph.com/blog?topics=Graph+Algorithm&amp;amp;utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_repost&amp;amp;utm_content=banner#list" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw0azgpsgm3wp9w5sd5wu.png" alt="Read more about graph algorithms on memgraph.com" width="800" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>photoshop</category>
      <category>theme</category>
      <category>uidesign</category>
      <category>productivity</category>
    </item>
    <item>
      <title>PageRank Algorithm for Graph Databases</title>
      <dc:creator>Vlasta Pavicic</dc:creator>
      <pubDate>Mon, 30 Jan 2023 14:34:44 +0000</pubDate>
      <link>https://forem.com/memgraph/pagerank-algorithm-for-graph-databases-39kk</link>
      <guid>https://forem.com/memgraph/pagerank-algorithm-for-graph-databases-39kk</guid>
      <description>&lt;p&gt;The most interesting and famous application of PageRank is certainly the one that actually sparked its creation. Google founders Larry Page and Sergey Brin needed &lt;a href="http://infolab.stanford.edu/~backrub/google.html"&gt;an algorithm to rank pages&lt;/a&gt; and provide users with the best possible search results.&lt;/p&gt;

&lt;p&gt;Using the PageRank algorithm, each page receives a ranking based on the number and importance of other pages that are linking to it. The pages with a higher page rank, increase the ranking of the page they link to more than the pages with a lower rank. &lt;/p&gt;

&lt;p&gt;In graph database terminology, the PageRank algorithm is used to measure the importance of each node based on the number of incoming relationships and the rank of the related source nodes. What the PageRank algorithm actually outputs is a probability distribution that represents the likelihood of visiting any particular node by randomly traversing the graph.&lt;/p&gt;

&lt;p&gt;So, it’s basically a node popularity contest. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Q6ae9Gw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-vin-visual.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Q6ae9Gw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-vin-visual.png" alt="memgraph-pagerank-vin-visual" width="880" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A widely used type of PageRank is Personalized PageRank, which is extremely useful in recommendation systems. With Personalized PageRank, you can restrain the random walk by allowing it to start only from one of the nodes in a given set, and jump only to one of the nodes in a given set. This type of PageRank brings out central nodes from the perspective of that set of specific nodes. For example, &lt;a href="https://dl.acm.org/doi/10.1145/2488388.2488433"&gt;Twitter uses Personalized PageRank&lt;/a&gt;  to recommend who to follow online. &lt;/p&gt;

&lt;p&gt;The animation below shows the results of PageRank on a simple network. A sequel of a well-liked movie will automatically be more popular than just a random new title because it already has an established fan base. In graph terms, the biggest node pointing to an adjacent node makes it more important.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OzVVXniX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-movie-animation.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OzVVXniX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-movie-animation.gif" alt="gif animation" width="600" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PageRank can be used as a measure of influence that can be used on a variety of applications, not just on website and movie rankings.&lt;/p&gt;

&lt;h2&gt;
  
  
  PageRank use cases
&lt;/h2&gt;

&lt;p&gt;If a social network or a search engine are not the products you are developing, check out how you can utilize PageRank in various other use cases or knowledge graphs built to infer knowledge in these niches. &lt;/p&gt;

&lt;h3&gt;
  
  
  Recommendation Engines
&lt;/h3&gt;

&lt;p&gt;In Recommendation Engines, PageRank algorithm can be utilized &lt;a href="https://memgraph.com/blog/five-recommendation-algorithms-no-recommendation-engine-is-whole-without"&gt;to recommend products&lt;/a&gt; that match the target user's preferences or are currently trending among all the other users. The algorithm considers the number of purchases and the reliability of the users who bought or reviewed the product. &lt;/p&gt;

&lt;p&gt;A reliable user has a valid usage history and reviews, while unreliable users are fake customers whose purpose is to artificially inflate the metrics of certain products to make them appear more desirable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Lineage
&lt;/h3&gt;

&lt;p&gt;Knowing the importance of documents in the data lineage graph has two important applications: impact analysis and system reliability. &lt;/p&gt;

&lt;p&gt;In events of adding new data property, migration or major updates, such as merging data sources after the acquisition, impact analysis can help assess the upstream and downstream impacts of such changes. &lt;/p&gt;

&lt;p&gt;PageRank can also help identify high-impact nodes that are required to remain highly reliable because they are used in many other places throughout the organization.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fraud Detection
&lt;/h3&gt;

&lt;p&gt;In &lt;a href="https://memgraph-staging.webflow.io/fraud-detection-insurance"&gt;fraud detection&lt;/a&gt;, PageRank can be used as an additional feature (input) to a machine learning algorithm, to improve classification and reduce the false positives. &lt;/p&gt;

&lt;p&gt;Users who are involved in &lt;a href="https://memgraph-staging.webflow.io/fraud-detection-card"&gt;fraudulent transactions with shared cards&lt;/a&gt; are more likely to be fraudsters. So the node ranks involved in these particular transactions can be a piece of valuable information that can be used in machine learning models to predict and detect fraud among individuals that have connections with known fraudsters in the network. &lt;/p&gt;

&lt;p&gt;Nodes can also be ranked based on how much money flows through each one to flag transactions that move much more money than what is average for a specific user. &lt;/p&gt;

&lt;h3&gt;
  
  
  Identity and Access Management
&lt;/h3&gt;

&lt;p&gt;While managing permission, it is important to restrict access to sensitive assets, as their exploitation could cause expensive damage to the company. In many systems, due to a lack of time and resources, high permissions are often given to people that don’t actually need them. &lt;/p&gt;

&lt;p&gt;PageRank can help identify which sensitive assets are accessible by many users to determine who, in fact, requires access and remove permissions for the rest of the users. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bQ1PlgSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-classified-visual.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bQ1PlgSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-classified-visual.png" alt="memgraph-pagerank-classified-visual" width="880" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Network Optimization
&lt;/h3&gt;

&lt;p&gt;Critical infrastructures are systems that can be represented as a network of highly interdependent nodes and relationships. Due to their nature, failure in one node may result in a cascade of failures in other nodes. PageRank can help identify nodes likely to fail and if they would cascade to other nodes in the network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QEHTD5Qm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-network-optimization.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QEHTD5Qm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-network-optimization.png" alt="memgraph-pagerank-network-optimization" width="880" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As energy infrastructure is also a network, using PageRank to identify vulnerabilities in the topology is invaluable and can save time, money and frustration for both companies and users. &lt;/p&gt;

&lt;h3&gt;
  
  
  Cyber Security
&lt;/h3&gt;

&lt;p&gt;As it is not feasible to remove absolutely every threat in the system. PageRank can help calculate probabilities of certain malignant events causing severe attacks. Just as PageRank’s original purpose was to determine which sites will more probably be randomly clicked on due to all the other sites pointing at it, in the security system, it can be used to point out which attack will more probably be performed, and consequences of which attacks will be more severe. &lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation in Memgraph
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://memgraph.com/docs/mage/query-modules/cpp/pagerank"&gt;Memgraph has implemented PageRank using C++&lt;/a&gt; which makes it ideal for use cases where performance is highly valuable. The graph needs to be directed, and the algorithm doesn’t take relationships' weight into account. &lt;/p&gt;

&lt;p&gt;Default arguments are the same as in the NetworkX PageRank implementation, so &lt;a href="https://memgraph.com/memgraph-for-networkx"&gt;if you are a NetworkX user&lt;/a&gt; it will be smooth sailing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;max_iterations&lt;/code&gt;: integer (default = 100) ➡ The maximum number of iterations within the PageRank algorithm.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;damping_factor&lt;/code&gt;: double (default = 0.85) ➡ PageRanks damping factor. This is the probability of continuing the random walk from a random node within the graph.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;stop_epsilon&lt;/code&gt;: double (default = 1e-5) ➡ Value used to terminate the iterations of PageRank. If the change from one iteration to another is lower than &lt;code&gt;stop_epsilon&lt;/code&gt;, execution is stopped.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To call PageRank in Memgraph use the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;pagerank.get&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;YIELD&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;RETURN&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="ss"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can try it out on Playground, in the Sandbox of the &lt;a href="https://playground.memgraph.com/sandbox/europe-gas-pipelines-scigrid"&gt;Europe gas pipelines&lt;/a&gt; dataset. Check the nodes with the highest value (that could cause problems if they fail) with the following query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;pagerank.get&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;YIELD&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;RETURN&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="ss"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8nbbOr52--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-eu-gas-pipline.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8nbbOr52--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/pagerank-algorithm-for-graph-databases/memgraph-pagerank-eu-gas-pipline.png" alt="memgraph-pagerank-eu-gas-pipline" width="880" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As with all the other algorithms in the MAGE open-source library, you can run PageRank only on a specific group of nodes with the &lt;a href="https://memgraph.com/docs/mage/how-to-guides/run-a-subgraph-module"&gt;&lt;code&gt;project()&lt;/code&gt; function&lt;/a&gt;. Save the sub-graph in a variable, then provide it as a first argument of the algorithm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;MATCH&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="py"&gt;n:&lt;/span&gt;&lt;span class="n"&gt;SpecificLabel&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;subgraph&lt;/span&gt;
&lt;span class="k"&gt;CALL&lt;/span&gt; &lt;span class="n"&gt;pagerank.get&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subgraph&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;YIELD&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;
&lt;span class="k"&gt;RETURN&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="ss"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your application is highly time-sensitive and nodes and relationships are arriving in a short period of time, use the &lt;a href="https://memgraph.com/docs/mage/algorithms/dynamic-graph-analytics/pagerank-online-algorithm"&gt;Dynamic PageRank&lt;/a&gt; which allows the preservation of the previously processed state. When entities are updated or new ones arrive in the graph, instead of restarting the algorithm over the whole graph, only the neighborhood objects of that arriving entity are processed at a constant time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;PageRank is a mature graph algorithm that hasn’t yet lost its relevance. Even more so, with the rise of graph database usage it will surely find its place in many management systems. For more examples of using PageRank check &lt;a href="https://memgraph.com/blog?topics=PageRank"&gt;Memgraph’s blog posts on the same topic&lt;/a&gt;, or explore more &lt;a href="https://memgraph.com/blog?topics=Graph+Algorithms"&gt;graph algorithms&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you ever have any doubts about whether you are using PageRank correctly, or you need help with implementing it into your use case, a welcoming community at &lt;a href="https://discord.com/invite/memgraph"&gt;Memgraph’s Discord server&lt;/a&gt; will be more than happy to help you integrate graphs and algorithms into your system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://memgraph.com/blog?topics=PageRank&amp;amp;utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_repost&amp;amp;utm_content=banner#list"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NWKqzkwo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://public-assets.memgraph.com/external/memgraph-read-more-gradient-1200.png" alt="Read more about page rank on  memgraph.com" width="880" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>memgraph</category>
      <category>algorithms</category>
      <category>pagerank</category>
      <category>graphdatabase</category>
    </item>
  </channel>
</rss>
