Longest Path in a Directed Acyclic Graph

Samual Sam
Updated on 16-Jun-2020 12:46:03

2K+ Views

One weighted directed acyclic graph is given. Another source vertex is also provided. Now we have to find the longest distance from the starting node to all other vertices, in the graph.We need to sort the nodes in topological sorting technique, and the result after the topological sort is stored into a stack. After that repeatedly popped from the stack and try to find the longest distance for each vertex.Input and OutputInput: The cost matrix of the graph. 0  5   3 -∞ -∞ -∞ -∞ 0   2  6 -∞ -∞ -∞ -∞  0  7  4  2 -∞ -∞ ... Read More

Customize Alert Box Position Using JavaScript

mkotla
Updated on 16-Jun-2020 12:45:56

3K+ Views

To customize the position of an alert box, use the CSS “top” and “left” properties. We have a custom alert box, which we’ve created using jQuery and styled with CSS.ExampleYou can try to run the following code to customize the position of an alert box −Live Demo                          function functionAlert(msg, myYes) {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);             confirmBox.find(".yes").unbind().click(function() {                confirmBox.hide();   ... Read More

What are Unchecked Exceptions in Java

Sharon Christine
Updated on 16-Jun-2020 12:45:47

2K+ Views

An unchecked exception is the one which occurs at the time of execution. These are also called as Runtime Exceptions. These include programming bugs, such as logic errors or improper use of an API. Runtime exceptions are ignored at the time of compilation. If you have declared an array of size 5 in your program, and trying to call the 6th element of the array then an ArrayIndexOutOfBoundsExceptionexception occurs.ExampleLive Demopublic class Unchecked_Demo {    public static void main(String args[]) {       int num[] = {1, 2, 3, 4};       System.out.println(num[5]);    } }OutputException in thread "main" java.lang.ArrayIndexOutOfBoundsException: ... Read More

Configure Apache for Python CGI Programming

Rajendra Dharmkar
Updated on 16-Jun-2020 12:45:17

2K+ Views

Configure Apache Web server for CGITo get your server run CGI scripts properly, you have to configure your Web server. We will discuss how to configure your Apache web server to run CGI scripts.Using ScriptAliasYou may set a directory as ScriptAlias Directive (options for configuring Apache). This way, Apache understands that all the files residing within that directory are CGI scripts. This may be the most simple way to run CGI Scripts on Apache. A typical ScriptAlias line looks like following in httpd.conf file of your Apache web server.ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/So, search ScriptAlias in your httpd.conf file and uncomment the ... Read More

Find If a Graph is Bipartite

Arjun Thakur
Updated on 16-Jun-2020 12:41:36

4K+ Views

A graph is said to be a bipartite graph, when vertices of that graph can be divided into two independent sets such that every edge in the graph is either start from the first set and ended in the second set, or starts from the second set, connected to the first set, in other words, we can say that no edge can found in the same set.Checking of a bipartite graph is possible by using the vertex coloring. When a vertex is in the same set, it has the same color, for another set, the color will change.Input and OutputInput: ... Read More

Maximum Bipartite Matching

karthikeya Boyini
Updated on 16-Jun-2020 12:37:58

9K+ Views

The bipartite matching is a set of edges in a graph is chosen in such a way, that no two edges in that set will share an endpoint. The maximum matching is matching the maximum number of edges.When the maximum match is found, we cannot add another edge. If one edge is added to the maximum matched graph, it is no longer a matching. For a bipartite graph, there can be more than one maximum matching is possible.Input and OutputInput: The adjacency matrix. 0 1 1 0 0 0 1 0 0 1 0 0 0 0 1 0 0 ... Read More

Shortest Path with Exactly K Edges

Samual Sam
Updated on 16-Jun-2020 12:34:11

691 Views

One directed graph is provided with the weight between each pair of vertices, and two vertices u and v are also provided. Our task is to find the shortest distance from vertex u to vertex v, with exactly k number of edges. To solve this problem, we will start from vertex u and go to all adjacent vertices and recur for adjacent vertices using the k value as k - 1.Input and OutputInput: The cost matrix of the graph. 0 10 3 2 ∞  0 ∞ 7 ∞  ∞ 0 6 ∞  ∞ ∞ 0 Output: Weight of the shortest ... Read More

Retrieve Cookies in Python CGI Programming

Rajendra Dharmkar
Updated on 16-Jun-2020 12:32:59

1K+ Views

Retrieving CookiesIt is very easy to retrieve all the set cookies. Cookies are stored in CGI environment variable HTTP_COOKIE and they will have following form −key1 = value1;key2 = value2;key3 = value3....Here is an example of how to retrieve cookies.#!/usr/bin/python # Import modules for CGI handling from os import environ import cgi, cgitb if environ.has_key('HTTP_COOKIE'):    for cookie in map(strip, split(environ['HTTP_COOKIE'], ';')):       (key, value ) = split(cookie, '=');       if key == "UserID":          user_id = value       if key == "Password":          password = value print ... Read More

Difference Between GET and POST in Python CGI Programming

Rajendra Dharmkar
Updated on 16-Jun-2020 12:31:23

2K+ Views

GET and POST MethodsYou must have come across many situations when you need to pass some information from your browser to web server and ultimately to your CGI Program. Most frequently, browser uses two methods two pass this information to web server. These methods are GET Method and POST Method.Passing Information using GET methodThe GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character as follows −http://www.test.com/cgi-bin/hello.py?key1=value1&key2=value2The GET method is the default method to pass information from browser to web server and it produces a long ... Read More

Bootstrap 4 Flex Column Reverse Class

Ricky Barnes
Updated on 16-Jun-2020 12:30:39

918 Views

Use the flex-*-column-reverse class to display flex items vertically and reversed on different screen sizes.Here’s the example of reversing flex items on medium device using “flex-md-column-reverse” class −   One   Two   Three In the same way, set for large devices using “flex-lg-column-reverse” class −   One   Two   Three Implementing the .flex-*-column-reverse class −ExampleLive Demo       Bootstrap Example                             Example     Change the browser size to see the effect:     Default           One       Two       Three         Flex on differet screen size (Medium-Reverse)           One       Two       Three         Flex on different screen size (Large-Reverse)           One       Two       Three      

Advertisements