Skip to content

Implement Prim's algorithm to find the minimum spanning tree of a given weighted undirected graph.

Notifications You must be signed in to change notification settings

AdamRosas27/prims

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Prims Algorithm

Prim's algorithm is a greedy algorithm that finds the minimum spanning tree (MST) for a weighted undirected graph. The MST is a tree that connects all vertices together with the minimum possible total edge weight. It's widely used in networking, circuit design, and other fields. This is an implementation of Prim's algorithm to find the minimum spanning tree of a given weighted undirected graph.

Table of Contents

Introduction

The provided project consists of Python code that defines a Graph class and a main script for graph analysis. The primary purpose of this project is to demonstrate the implementation of a graph data structure and to perform graph-related operations, particularly finding the Minimum Spanning Tree (MST) using Prim's algorithm.

The goals of this project include:

  • Creating a reusable Graph class: The project defines a Graph class with methods for adding vertices and edges, computing the MST, and printing graph information.

  • Implementing Prim's algorithm: The code showcases the application of Prim's algorithm to find the MST of a graph.

  • Providing graph analysis tools: The project offers methods to print information about the graph's edges and total weight, both with and without the MST.

Features

  • Graph Data Structure: The script defines a Graph class, which serves as a fundamental data structure for working with graphs. It allows users to add vertices and edges, making it suitable for graph-related operations.

  • Prim's Algorithm: The script demonstrates the implementation of Prim's algorithm, a widely used algorithm for finding the Minimum Spanning Tree (MST) of a graph. This feature enables users to efficiently compute MSTs.

  • Customization: Users can easily customize and extend the script for their specific graph analysis needs. Whether it's adding more vertices, defining new edges, or modifying the behavior of the graph, the script is adaptable.

  • Interactive Usage: The script is designed to be run interactively from the command line, allowing users to see the results of graph analysis operations in real-time.

License

N/A

Acknowledgements

  • Adam Rosas

About

Implement Prim's algorithm to find the minimum spanning tree of a given weighted undirected graph.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages