I need your help, I created this two classes I need a method in Graph to delete an Arch from the ArrayList that I have in the hashmap. I tried like this in the class Graph: but when I tested it in my test main the result is that nothing changed in my ArrayList in the hashmap. someone can help
Tag: graph
Making a island large leetcode – spotting mistake Java
I am working on LeetCode problem 827. Making A Large Island: You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-directionally connected group of 1s. Example 1: Input: grid =
Does this look like an efficient way to find vertices which have no outgoing edges in a graph (JGrapthT)?
I am using JGraphT for holding about 150,000 (or thereabouts) vertices in an in-memory graph. This a directed graph and each vertex is going to have { 0 | 1 } outgoing edges. I want to find retrieve the set of vertices which have no outgoing edges. Here’s what I have attempted: This perhaps, is a naive attempt. I am
Scanning input in HashMap of String and ArrayList
I need to add all these cities in a HashMap of String and ArrayList And I am unable to add these , I have the structure So now i need to add banglore and then if banglore is present i will add Hyderabad to the ArrayList and again I’ll scan for the next element again banglore is present so add
Experimental Analysis of an Algorithm – How to prove that the graph is O(nlogn)?
This question is probably stupid, but I’ve been trying to figure this out for hours and I still couldn’t find anything about it. Probably I’m just too lost. So basically, I’m analysing an algorithm by doing an asymptotic and experimental analysis. The asymptotic analysis went well and I concluded that my algorithm is O(nlogn). The problem is the experimental analysis.
Add new edge to Graph and check if total weight is reduced
I’m new to Graphs and I’m trying to solve this problem in Java: Given a Graph with N nodes and N-1 weighted bidirectional edges, the algorithm must respond YES if a new edge ‘q’ allows to reduce the overall weight of the graph, NO otherwise. The edge ‘q’ satisfies this condition if there is an edge ‘e’ such that it
Array out of bound exception while doing topological sort
This code takes the no. of nodes in a graph and creates the graph with the number of nodes and then the user has to input the one-way edges between two vertices.(The formed Graph is a Directed Acyclic Graph or DAG). The graph is then sorted by the topological sorting function topoSort The problem is in the topoSortRE method which
Merge sets when two elements in common
This is the follow up of compare sets I have I want to merge the sets when there are two elements in common. For example 0,1,2 and 0,2,6 has two elements in common so merging them to form [0,1,2,6]. Again [0,1,2,6] and [2,6,7] has 2 and 6 common. so merging them and getting [0,1,2,6,7]. The final output should be :
Design for defining graphs or flowing structures
I’m trying to create a system for representing and designing graphs in an easy way. That means it should be easy to create some graphical representation from the data structure but it should also be easy to store the structure and do easy calculation on it. Easy calulations in this sence are questions like which nodes are the next nodes