How to i know if this graph is directed or undirected? - data-structures

My teacher didnt specify what kind of graph is this so im confused how to answer some of the questions. Need help to identify if this is directed or undirected graph

An easy way to check that your graph is undirected is, once the adjacency matrix is provided is to notice that it is symmetric, if the graph is directed it cannot be simmetric because it would be an entry which A_i,j different of A_j,i.

Related

longest path in undirected vs directed graph

I need to solve a longest path problem for graphs that are both directed and non-directed (unweighted in both cases).
For directed graph, it is pretty easy to find dynamic programming algorithms that are able to solve the problem in pseudopolynomial time, starting at some node, and calculating the longest path for subproblems until every problem has been looked at.
Can I do a similar thing for at non-directed graph? I cant seem to find any litterature about it?
Every directed graph algorithm works on undirected graphs. Simply treat each edge as two directed edges with the same weight.

A* algorithm for undirected graph

I know A* algorithm can be used in directed graph, can we use it in undirected graph as well?
The A* algorithm is generic for all the graphs. So, yes, you can use it with an undirected graph.
In an undirected graph, all edges are by definition bidirectional. So it's like a directional graph where for every edge, you'd have an edge in the opposite direction. In consequence, if you have an implementation of the algorithm working for directed graphs, you should be able to extend it to undirected graphs according to this principle.
The only difficulty here is to have the appropriate data structure. If implementing the edges with a matrix, you just have to make sure that the matrix is symmetric. If you use adjacency lists, be sure that everytime you add an edge from a to b, the edge of b to a is added, with the same cost factor.

Fleury's algorithm for oriented graph

I am going to implement an algorithm for finding an Eulerian path in an oriented graph and am deciding which algorithm would be the best.
I have found Fleury's algorithm which seems neat but all the examples I have seen consider only non-oriented graphs. Does anyone know if this will work with an oriented graph?
It seems to me that adjacency list can be specified for every single vertex so it should work but I am not 100% sure.
What if there are paralel edges in the graph?
Thanks for any answer!
In a directed graph the inbound and outbound edge must be the same:http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK4/NODE165.HTM

minimum cost to make an undirected graph disconnected

What is the minimum cost to make an undirected weighted(positive weight) graph disconnected.
i mean i have to find out those edges which removal disconnect the graph and their cost is minimized.
I have following ideas...
1.find out all the bridges of the graph . then the bridge edge of minimum weight wiil be the ans.
2.if there is no bridge that means all the nodes are in a cycle(i'm not sure about it). then i sort the edge according to their weight and the sum of the two minimum edge weight will be the ans.
The graph has no self loop.
Is this algo correct?
This question looks to be the same question answered by the study of "minimum cuts" in graphs. I would recommend the following reading here and here to learn more about why it works from a graph theoretic point of view - the link provides some pseudocode as well.
Regarding your proposed algorithm, finding the bridges in a graph may get tricky.. you would have to inspect both endpoints and their local structure to confirm the existence of a bridge.. using edge contraction perhaps would be simpler to implement.

Data Structures: Wikipedia-like Tree

I am currently in the process of developing an ontology, a web hierarchy of categories of everything (think persons, places, things). The finished product should be something that allows me to navigate from Technology->Computers->Laptops->USB Ports, but also from Movies->Minority Report->Computers->etc.
I need an efficient data structure to group these. I need a tree-like graph, but a special tree that allows child nodes to have multiple parent nodes.
In thinking over this, I have realized that Wikipedia is an imperfect model for this. In fact, they have a hierarchy starting here that is essentially exactly what I need. I see that they used a directed graph, but I am wondering what the differences/drawbacks between this directed graph, a directed acyclic graph, and a polytree are. I have tried researching it, but I don't quite understand the differences. Any help would be greatly appreciated. Thank you!
I think the articles at Wikipedia give a good overview:
A directed graph is a set of nodes connected by edges which have a direction associated with them.
A directed acyclic graph (DAG) is a directed graph with no directed cycles.
A polytree (also called directed tree) is a directed graph with exactly one undirected path between any two vertices. In other words, a polytree is a directed graph whose underlying undirected graph is a tree, or equivalently, a connected directed acyclic graph for which there are no undirected cycles either.
So I think you search for a connected directed acyclic graph. Altough the Wikipedia category system allows cycles, they are unwanted.

Resources