Giter VIP home page Giter VIP logo

directedgraph's Introduction

directedGraph

Undirected Graph Implementation

Overview This project implements an undirected graph using parallel adjacency lists. The graph is comprised of vertices and edges. Vertices are unique entities identified by a name, while edges link two distinct vertices together.

Class Structure UndirectedGraph: The primary class that encapsulates the entire graph structure.

VertexNode: Represents a vertex in the graph. Each vertex has a name and pointers to its edge lists.

EdgeNode: Represents an edge in the graph. An edge connects two distinct vertices.

Features addVertex(String s): Adds a vertex with the specified name s to the graph.

addEdge(String n1, String n2): Adds an undirected edge between vertices n1 and n2.

bfs(String v): Performs a breadth-first search starting from the vertex named v. It returns the BFS traversal order if all vertices are reachable from v; otherwise, it returns an empty string.

printGraph(): Prints the graph's adjacency list representation.

main(): A tester function which reads from a specified input file to construct the graph and then prints the graph and performs BFS.

Usage To use this project:

Ensure you have a Java environment set up. Compile the UndirectedGraph class. Run the main method, specifying the input file path as an argument. The program will read the input file, construct the graph, and then print it. It will also demonstrate the BFS traversal from given starting vertices. Input File Structure The input file should be structured as follows:

The first line should contain all the vertex names, separated by spaces. Each subsequent line should represent an edge, with two vertex names separated by a space.

directedgraph's People

Contributors

matthewlutz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.