me.gosimple.nbvcxz.resources.AdjacencyGraph Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nbvcxz Show documentation
Show all versions of nbvcxz Show documentation
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.
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;
}
}