Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with CCM metric addition v3 #524

Open
User123363 opened this issue May 21, 2021 · 0 comments
Open

Problem with CCM metric addition v3 #524

User123363 opened this issue May 21, 2021 · 0 comments

Comments

@User123363
Copy link

To fix the CCM metric it was decided to integrate the FindConnectedComponents Java class into the jpeek project and then call it before constructing the CCM.xsl file [1] and add the result of the call to the ncc variable in the file. Thus, the problem of xslt algorithm implementation, related to the lack of possibility to redefine variable values and as a consequence the marking of visited nodes, disappears.

[1] The FindConnectedComponents class can be called in the App class of org.jpeek:

Снимок экрана 2021-05-21 в 11 36 59

Class FindConnectedComponents:

package com.company;

import java.util.ArrayList;

class FindConnectedComponents
{
    int V;
    ArrayList<ArrayList<Integer>> graph;

    FindConnectedComponents(int V)
    {
        this.V = V;
        graph = new ArrayList<>();

        for (int i = 0; i < V; i++) {
            graph.add(i, new ArrayList<>());
        }
    }

    void DFS(int v, boolean[] visited)
    {
        visited[v] = true;
        System.out.print(v + " ");
        for (int x : graph.get(v)) {
            if (!visited[x])
                DFS(x, visited);
        }
    }

    int connectedComponents()
    {
        int countConnectedComponents = 0;
        boolean[] visited = new boolean[V];
        for (int v = 0; v < V; ++v) {
            if (!visited[v]) {
                DFS(v, visited);
                System.out.println();
                countConnectedComponents++;
            }
        }
        return countConnectedComponents;
    }


    void addEdge(int src, int dest)
    {
        graph.get(src).add(dest);
        graph.get(dest).add(src);
    }

    public static void main(String[] args)
    {
        FindConnectedComponents f = new FindConnectedComponents(7);

        f.addEdge(1, 0);
        f.addEdge(2, 3);
        f.addEdge(3, 4);
        f.addEdge(4, 5);
        f.addEdge(5, 6);

        System.out.println("Following are connected components");
        int countConnectedComponents = f.connectedComponents();

        System.out.print("Count Connected Components: ");
        System.out.print(countConnectedComponents);

    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants