All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.gosimple.nbvcxz.resources.AdjacencyGraph Maven / Gradle / Ivy

Go to download

Nbvcxz takes heavy inspiration from the zxcvbn library built by Dropbox, and in a lot of ways is similar. I built this library to be heavily extensible for every use case, with sane defaults.

There is a newer version: 1.5.1
Show newest version
package me.gosimple.nbvcxz.resources;

import java.util.HashMap;

/**
 * @author Adam Brusselback.
 */
public class AdjacencyGraph
{
    private final HashMap keyMap;
    private final String name;

    /**
     * @param name   the name of the graph
     * @param keyMap the keyMap for the graph
     */
    public AdjacencyGraph(String name, HashMap keyMap)
    {
        this.name = name;
        this.keyMap = keyMap;
    }

    /**
     * @return The key map for this adjacency graph
     */
    public HashMap getKeyMap()
    {
        return keyMap;
    }


    /**
     * Calculates the average "degree" of a keyboard or keypad. On the qwerty
     * keyboard, 'g' has degree 6, being adjacent to 'ftyhbv' and '\' has degree 1.
     *
     * @return the average degree for this keyboard or keypad
     */
    public double getAverageDegree()
    {
        return AdjacencyGraphUtil.calcAverageDegree(keyMap);
    }

    /**
     * @return Returns the name
     */
    public String getName()
    {
        return name;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy