Giter Site home page Giter Site logo

weisslertal / directed_graphs Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 24 KB

This program reads a directed graph from a text file. when a search word is entered (that appears in the graph) it prints all possible termination nodes from that word and the probability of getting to them. probabilities are calculated according to the weights.

License: MIT License

Java 100.00%

directed_graphs's Introduction

Author: Tal Weissler

This program reads a directed graph from a text file. when a search word is entered (that appears in the graph) it prints all possible termination nodes from that word and the probability of getting to them. probabilities are calculated according to the weights.

Explenation of what a directed graph is and of basic related terms (such as nodes and edges): http://mathinsight.org/definition/directed_graph

Input:

The input will be a text file. Change the variable "fileAddress" to the path to your file. The file describes the edges of the graph. It is formatted as a simple text file where each line describes a single edge using a colon-delimited format as such:

ORIGINATING_WORD:WEIGHT_NUMBER:TERMINATING_WORD

For example: someWord:1:anotherWord

Restrictions: the weights have to be non-negative numbers but don't have to be integers (1.5384 is allowed). The words can contain all keys including whitespace, except for the string "Endless Loop". The input search word has to be a word that exists in the graph for the program to compute a proper output.

Output:

The program prints every possible termination node (nodes from which there is no outgoing edge) that can be reached from the starting node (chosen by entered search word). The program also prints the chances of getting to each termination node assuming a traveler will travel the graph by selecting an outgoing edge in a weighted (according to the edge weight)uniformly distributed random selection.

Special cases: in case a termination node is inserted as input, that word will be printed with the probability of 1. In case of loops in the graphs, the program will print "Endless Loop" as one of the termination nodes along with the probability of entering and getting stuck in a loop.

Example:

For the input file:

dad:1:mom/* !&
dad:3:child
child:5.84765:sister
child:10:brother
sister:1:child

And input search word:

dad

The output will be:

termination word: mom/* !&, probability: 0.25
termination word: Endless Loop, probability: 0.27674371279022436
termination word: brother, probability: 0.4732562872097756

directed_graphs's People

Contributors

weisslertal 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.