I have a program that you have attached and remove nodes from a graph, then make BFS and DFS run traversals I'm trying to
So I basically read When I try to attach a new node, write it over the current proximity matrix and replace it with a single new node I think I I know that is doing that ... because my But what do I want to achieve without overwriting it? / P> > FYI, here is the connecting node method: by eliminating the adjacency matrix and changing it with a new one with the updated size All cells will be zero (from, from) and (from, to), you need to create a new adjacent matrix with the new size, copy the data from the old, and then only overwrite the old. Add and
connect nodes on runtime ... Then I want to hit users with a
add parent to the parent button which will allow a child to Appropriately connects
AddButton.addActionListener (New ActionListener) {Public Zero actionPerformed (ActionEvent E) {nodes nx = new nodes ("x", nodeX, nodeY, nodeWidth, nodeHeight); appendNode (rootNode, Nx);}}); }
x Sounds as
A .
appendNode () function tries to update proximity matrix by making a new one with the old overwritten and new nodeList size:
if the public is zero connectNode (from nodes, nodes) {// matrix is empty. (AdjMatrix = = null) {// Set matrix [row] [color] Size list size for size of node size = nodelist. Size (); // Set Matrix set dimension ... (6x6 nodes list) adjmatrix = new int [size] [size]; } Int fromNode = nodeList.indexOf (to); Int toNode = nodeList.indexOf (to); // Connect node A to B and B to A, set that I, j position = 1 adjmatrix [fromNode] [toNode] = 1; Adjmatrix [toNode] [node] = 0; } Edit: Add / add x node list adnode (child); // Loop to connect again through all the nodes, plus a new ... then create new adjmatrix int newsize = nodeList.size (); // Create a new Ady matrix of new shape ... int [] [] adjmatrixcopy = new int [newSize] [newSize]; Int fromNode = nodeList.indexOf (original); Int toNode = nodlist.indexoff (hair); Adjmatrixcopy [node] [toNode] = 1; Adjmatrixcopy [toNode] [fromNode] = 0; // Copy the new matrix for adjmatrix data ... (int i = 0; i & lt; adjmatrix.length; i ++) {for (int j = 0; j & lt; adjmatrix [i] length ; J ++) {adjmatrixcopy [i] [j] = xmatics [i] [j]; }} // now need to add new addition node / adjmatrix = null; }
No comments:
Post a Comment