    /**
     * This runs a number of iterations in the computation and stops when enough
     * precision has been reached. A maximum number of iterations to perform is
     * supplied. NOTE: For maxNrIterations > 0 at least one iteration will be
     * run, regardless if good precision has already been reached or not. This
     * method also ignores the global limit defined by maxIterations.
     * @param maxNrIterations
     *            The maximum number of iterations to run.
     * @return the number of iterations performed. if this is lower than the
     *         given maxNrIterations the desired precision has been reached.
     */
    protected int runIterations( int maxNrIterations )
    {
        while ( true )
        {
            values = new HashMap<>();
            totalIterations = 0;

            // generate a random start vector
            Random random = new Random( System.currentTimeMillis() );
            for ( Node node : nodeSet )
            {
                values.put( node, random.nextDouble() );
            }
            normalize( values );

            if ( maxNrIterations <= 0 )
            {
                return 0;
            }
            int localIterations = 0;

            // Do iterations
            while ( localIterations < maxNrIterations )
            {
                Map<Node,Double> oldValues = values;
                localIterations += runInternalIteration();
                if ( timeToStop( oldValues, values ) )
                {
                    break;
                }
            }

            // Check result
            if ( makeSureValueCorrespondsToMostSignificantEigenvector() )
            {
                return localIterations;
            }
            else
            {
                // Value has not converged to an eigenvector that corresponds to the highest eigenvalue.
                // Restart calculation.
            }
        }
    }

    /**
     * This runs a number of iterations in the computation and stops when enough
     * precision has been reached. A maximum number of iterations to perform is
     * supplied. NOTE: For maxNrIterations > 0 at least one iteration will be
     * run, regardless if good precision has already been reached or not. This
     * method also ignores the global limit defined by maxIterations.
     * @param maxNrIterations
     *            The maximum number of iterations to run.
     * @return the number of iterations performed. if this is lower than the
     *         given maxNrIterations the desired precision has been reached.
     */
    protected int runIterations( int maxNrIterations )
    {
        while ( true )
        {
            values = new HashMap<Node,Double>();
            totalIterations = 0;

            // generate a random start vector
            Random random = new Random( System.currentTimeMillis() );
            for ( Node node : nodeSet )
            {
                values.put( node, random.nextDouble() );
            }
            normalize( values );

            if ( maxNrIterations <= 0 )
            {
                return 0;
            }
            int localIterations = 0;

            // Do iterations
            while ( localIterations < maxNrIterations )
            {
                Map<Node,Double> oldValues = values;
                localIterations += runInternalIteration();
                if ( timeToStop( oldValues, values ) )
                {
                    break;
                }
            }

            // Check result
            if ( makeSureValueCorrespondsToMostSignificantEigenvector() )
            {
                return localIterations;
            }
            else
            {
                // Value has not converged to an eigenvector that corresponds to the highest eigenvalue.
                // Restart calculation.
            }
        }
    }

Replace Generic With Diamond HashMap<Node,Double> with HashMap<> in method protected runIterations(maxNrIterations int) : int from class org.neo4j.graphalgo.impl.centrality.EigenvectorCentralityBase


    /**
     * Default constructor.
     * @param singleSourceShortestPath
     *            Underlying singleSourceShortestPath.
     * @param zeroValue
     *            Default value.
     * @param nodeSet
     *            A set containing the nodes for which centrality values should
     *            be computed.
     * @param distanceComparator
     *            Object being able to compare eccentricity values (path
     *            distances), in order to sort out the largest.
     */
    public NetworkDiameter(
        SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
        ShortestPathCostType zeroValue, Set<Node> nodeSet,
        Comparator<ShortestPathCostType> distanceComparator )
    {
        super( singleSourceShortestPath, null, zeroValue, nodeSet );
        this.distanceComparator = distanceComparator;
        eccentricity = new Eccentricity<>( singleSourceShortestPath, zeroValue, nodeSet, distanceComparator );
    }

    /**
     * Default constructor.
     * @param singleSourceShortestPath
     *            Underlying singleSourceShortestPath.
     * @param zeroValue
     *            Default value.
     * @param nodeSet
     *            A set containing the nodes for which centrality values should
     *            be computed.
     * @param distanceComparator
     *            Object being able to compare eccentricity values (path
     *            distances), in order to sort out the largest.
     */
    public NetworkDiameter(
        SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
        ShortestPathCostType zeroValue, Set<Node> nodeSet,
        Comparator<ShortestPathCostType> distanceComparator )
    {
        super( singleSourceShortestPath, null, zeroValue, nodeSet );
        this.distanceComparator = distanceComparator;
        eccentricity = new Eccentricity<ShortestPathCostType>(
            singleSourceShortestPath, zeroValue, nodeSet, distanceComparator );
    }

Replace Generic With Diamond Eccentricity<ShortestPathCostType> with Eccentricity<> in method public NetworkDiameter(singleSourceShortestPath SingleSourceShortestPath<ShortestPathCostType>, zeroValue ShortestPathCostType, nodeSet Set<Node>, distanceComparator Comparator<ShortestPathCostType>) from class org.neo4j.graphalgo.impl.centrality.NetworkDiameter


    /**
     * Default constructor.
     * @param singleSourceShortestPath
     *            Underlying singleSourceShortestPath.
     * @param zeroValue
     *            Default value.
     * @param nodeSet
     *            A set containing the nodes for which centrality values should
     *            be computed.
     * @param distanceComparator
     *            Object being able to compare eccentricity values (path
     *            distances), in order to sort out the smallest.
     */
    public NetworkRadius(
        SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
        ShortestPathCostType zeroValue, Set<Node> nodeSet,
        Comparator<ShortestPathCostType> distanceComparator )
    {
        super( singleSourceShortestPath, null, zeroValue, nodeSet );
        this.distanceComparator = distanceComparator;
        eccentricity = new Eccentricity<>( singleSourceShortestPath, zeroValue, nodeSet, distanceComparator );
    }

    /**
     * Default constructor.
     * @param singleSourceShortestPath
     *            Underlying singleSourceShortestPath.
     * @param zeroValue
     *            Default value.
     * @param nodeSet
     *            A set containing the nodes for which centrality values should
     *            be computed.
     * @param distanceComparator
     *            Object being able to compare eccentricity values (path
     *            distances), in order to sort out the smallest.
     */
    public NetworkRadius(
        SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
        ShortestPathCostType zeroValue, Set<Node> nodeSet,
        Comparator<ShortestPathCostType> distanceComparator )
    {
        super( singleSourceShortestPath, null, zeroValue, nodeSet );
        this.distanceComparator = distanceComparator;
        eccentricity = new Eccentricity<ShortestPathCostType>(
            singleSourceShortestPath, zeroValue, nodeSet, distanceComparator );
    }

Replace Generic With Diamond Eccentricity<ShortestPathCostType> with Eccentricity<> in method public NetworkRadius(singleSourceShortestPath SingleSourceShortestPath<ShortestPathCostType>, zeroValue ShortestPathCostType, nodeSet Set<Node>, distanceComparator Comparator<ShortestPathCostType>) from class org.neo4j.graphalgo.impl.centrality.NetworkRadius


    /**
     * The calculation is normally only done once, this resets it so it can be
     * run again. Also used locally for initialization.
     */
    public void reset()
    {
        doneCalculation = false;
        centralities = new HashMap<>();
        for ( Node node : nodeSet )
        {
            centralities.put( node, zeroValue );
        }
    }

    /**
     * The calculation is normally only done once, this resets it so it can be
     * run again. Also used locally for initialization.
     */
    public void reset()
    {
        doneCalculation = false;
        centralities = new HashMap<Node,CentralityType>();
        for ( Node node : nodeSet )
        {
            centralities.put( node, zeroValue );
        }
    }

Replace Generic With Diamond HashMap<Node,CentralityType> with HashMap<> in method public reset() : void from class org.neo4j.graphalgo.impl.centrality.ShortestPathBasedCentrality


    @Override
    public WeightedPath findSinglePath( Node start, Node end )
    {
        lastMetadata = new Metadata();
        AStarIterator iterator = new AStarIterator( start, end );
        while ( iterator.hasNext() )
        {
            Node node = iterator.next();
            GraphDatabaseService graphDb = node.getGraphDatabase();
            if ( node.equals( end ) )
            {
                // Hit, return path
                double weight = iterator.visitData.get( node.getId() ).wayLength;
                final Path path;
                if ( start.getId() == end.getId() )
                {
                    // Nothing to iterate over
                    path = PathImpl.singular( start );
                }
                else
                {
                    LinkedList<Relationship> rels = new LinkedList<>();
                    Relationship rel = graphDb.getRelationshipById(
                            iterator.visitData.get( node.getId() ).cameFromRelationship );
                    while ( rel != null )
                    {
                        rels.addFirst( rel );
                        node = rel.getOtherNode( node );
                        long nextRelId = iterator.visitData.get( node.getId() ).cameFromRelationship;
                        rel = nextRelId == -1 ? null : graphDb.getRelationshipById( nextRelId );
                    }
                    path = toPath( start, rels );
                }
                lastMetadata.paths++;
                return new WeightedPathImpl( weight, path );
            }
        }
        return null;
    }

    @Override
    public WeightedPath findSinglePath( Node start, Node end )
    {
        lastMetadata = new Metadata();
        AStarIterator iterator = new AStarIterator( start, end );
        while ( iterator.hasNext() )
        {
            Node node = iterator.next();
            GraphDatabaseService graphDb = node.getGraphDatabase();
            if ( node.equals( end ) )
            {
                // Hit, return path
                double weight = iterator.visitData.get( node.getId() ).wayLength;
                final Path path;
                if ( start.getId() == end.getId() )
                {
                    // Nothing to iterate over
                    path = PathImpl.singular( start );
                }
                else
                {
                    LinkedList<Relationship> rels = new LinkedList<Relationship>();
                    Relationship rel = graphDb.getRelationshipById(
                            iterator.visitData.get( node.getId() ).cameFromRelationship );
                    while ( rel != null )
                    {
                        rels.addFirst( rel );
                        node = rel.getOtherNode( node );
                        long nextRelId = iterator.visitData.get( node.getId() ).cameFromRelationship;
                        rel = nextRelId == -1 ? null : graphDb.getRelationshipById( nextRelId );
                    }
                    path = toPath( start, rels );
                }
                lastMetadata.paths++;
                return new WeightedPathImpl( weight, path );
            }
        }
        return null;
    }

Replace Generic With Diamond LinkedList<Relationship> with LinkedList<> in method public findSinglePath(start Node, end Node) : WeightedPath from class org.neo4j.graphalgo.impl.path.AStar


        protected void InitQueue()
        {
            queue = new DijkstraPriorityQueueFibonacciImpl<>( costComparator );
            queue.insertValue( startNode, startCost );
            mySeen.put( startNode, startCost );
        }

        protected void InitQueue()
        {
            queue = new DijkstraPriorityQueueFibonacciImpl<CostType>(
                    costComparator );
            queue.insertValue( startNode, startCost );
            mySeen.put( startNode, startCost );
        }

Replace Generic With Diamond DijkstraPriorityQueueFibonacciImpl<CostType> with DijkstraPriorityQueueFibonacciImpl<> in method protected InitQueue() : void from class org.neo4j.graphalgo.impl.shortestpath.Dijkstra.DijstraIterator


        /**
         * This checks if a node has been seen by the other iterator/traverser
         * as well. In that case a path has been found. In that case, the total
         * cost for the path is calculated and compared to previously found
         * paths.
         *
         * @param currentNode The node to be examined.
         * @param currentCost The cost from the start node to this node.
         * @param otherSideDistances Map over distances from other side. A path
         *            is found and examined if this contains currentNode.
         */
        protected void checkForPath( Node currentNode, CostType currentCost,
                HashMap<Node, CostType> otherSideDistances )
        {
            // Found a path?
            if ( otherSideDistances.containsKey( currentNode ) )
            {
                // Is it better than previously found paths?
                CostType otherCost = otherSideDistances.get( currentNode );
                CostType newTotalCost = costAccumulator.addCosts( currentCost,
                        otherCost );
                if ( foundPathsMiddleNodes == null )
                {
                    foundPathsMiddleNodes = new HashSet<>();
                }
                // No previous path found, or equally good one found?
                if ( foundPathsMiddleNodes.size() == 0
                     || costComparator.compare( foundPathsCost, newTotalCost ) == 0 )
                {
                    foundPathsCost = newTotalCost; // in case we had no
                    // previous path
                    foundPathsMiddleNodes.add( currentNode );
                }
                // New better path found?
                else if ( costComparator.compare( foundPathsCost, newTotalCost ) > 0 )
                {
                    foundPathsMiddleNodes.clear();
                    foundPathsCost = newTotalCost;
                    foundPathsMiddleNodes.add( currentNode );
                }
            }
        }

        /**
         * This checks if a node has been seen by the other iterator/traverser
         * as well. In that case a path has been found. In that case, the total
         * cost for the path is calculated and compared to previously found
         * paths.
         *
         * @param currentNode The node to be examined.
         * @param currentCost The cost from the start node to this node.
         * @param otherSideDistances Map over distances from other side. A path
         *            is found and examined if this contains currentNode.
         */
        protected void checkForPath( Node currentNode, CostType currentCost,
                HashMap<Node, CostType> otherSideDistances )
        {
            // Found a path?
            if ( otherSideDistances.containsKey( currentNode ) )
            {
                // Is it better than previously found paths?
                CostType otherCost = otherSideDistances.get( currentNode );
                CostType newTotalCost = costAccumulator.addCosts( currentCost,
                        otherCost );
                if ( foundPathsMiddleNodes == null )
                {
                    foundPathsMiddleNodes = new HashSet<Node>();
                }
                // No previous path found, or equally good one found?
                if ( foundPathsMiddleNodes.size() == 0
                     || costComparator.compare( foundPathsCost, newTotalCost ) == 0 )
                {
                    foundPathsCost = newTotalCost; // in case we had no
                    // previous path
                    foundPathsMiddleNodes.add( currentNode );
                }
                // New better path found?
                else if ( costComparator.compare( foundPathsCost, newTotalCost ) > 0 )
                {
                    foundPathsMiddleNodes.clear();
                    foundPathsCost = newTotalCost;
                    foundPathsMiddleNodes.add( currentNode );
                }
            }
        }

Replace Generic With Diamond HashSet<Node> with HashSet<> in method protected checkForPath(currentNode Node, currentCost CostType, otherSideDistances HashMap<Node,CostType>) : void from class org.neo4j.graphalgo.impl.shortestpath.Dijkstra.DijstraIterator


        @Override
        public Node next()
        {
            Node currentNode = queue.extractMin();
            CostType currentCost = mySeen.get( currentNode );
            // Already done with this node?
            if ( myDistances.containsKey( currentNode ) )
            {
                return null;
            }
            if ( limitReached() )
            {
                return null;
            }
            ++numberOfNodesTraversed;
            myDistances.put( currentNode, currentCost );
            // TODO: remove from seen or not? probably not... because of path
            // detection
            // Check if we have found a better path
            checkForPath( currentNode, currentCost, otherSeen );
            // Found a path? (abort traversing from this node)
            if ( otherDistances.containsKey( currentNode ) )
            {
                oneShortestPathHasBeenFound = true;
            }
            else
            {
                // Otherwise, follow all edges from this node
                for ( RelationshipType costRelationType : costRelationTypes )
                {
                    ResourceIterable<Relationship> relationships = Iterables.asResourceIterable(
                            currentNode.getRelationships( costRelationType, getDirection() ) );
                    try ( ResourceIterator<Relationship> iterator = relationships.iterator() )
                    {
                        while ( iterator.hasNext() )
                        {
                            Relationship relationship = iterator.next();
                            if ( limitReached() )
                            {
                                break;
                            }
                            ++numberOfTraversedRelationShips;
                            // Target node
                            Node target = relationship.getOtherNode( currentNode );
                            // Find out if an eventual path would go in the opposite
                            // direction of the edge
                            boolean backwardsEdge = relationship.getEndNode().equals( currentNode ) ^ backwards;
                            CostType newCost = costAccumulator.addCosts( currentCost, costEvaluator
                                    .getCost( relationship, backwardsEdge ? Direction.INCOMING : Direction.OUTGOING ) );
                            // Already done with target node?
                            if ( myDistances.containsKey( target ) )
                            {
                                // Have we found a better cost for a node which is
                                // already
                                // calculated?
                                if ( costComparator.compare( myDistances.get( target ), newCost ) > 0 )
                                {
                                    throw new RuntimeException( "Cycle with negative costs found." );
                                }
                                // Equally good path found?
                                else if ( calculateAllShortestPaths &&
                                        costComparator.compare( myDistances.get( target ), newCost ) == 0 )
                                {
                                    // Put it in predecessors
                                    List<Relationship> myPredecessors = predecessors.get( currentNode );
                                    // Dont do it if this relation is already in
                                    // predecessors (other direction)
                                    if ( myPredecessors == null || !myPredecessors.contains( relationship ) )
                                    {
                                        List<Relationship> predList = predecessors.get( target );
                                        if ( predList == null )
                                        {
                                            // This only happens if we get back to
                                            // the
                                            // start node, which is just bogus
                                        }
                                        else
                                        {
                                            predList.add( relationship );
                                        }
                                    }
                                }
                                continue;
                            }
                            // Have we found a better cost for this node?
                            if ( !mySeen.containsKey( target ) ||
                                    costComparator.compare( mySeen.get( target ), newCost ) > 0 )
                            {
                                // Put it in the queue
                                if ( !mySeen.containsKey( target ) )
                                {
                                    queue.insertValue( target, newCost );
                                }
                                // or update the entry. (It is important to keep
                                // these
                                // cases apart to limit the size of the queue)
                                else
                                {
                                    queue.decreaseValue( target, newCost );
                                }
                                // Update it
                                mySeen.put( target, newCost );
                                // Put it in predecessors
                                List<Relationship> predList = new LinkedList<>();
                                predList.add( relationship );
                                predecessors.put( target, predList );
                            }
                            // Have we found an equal cost for (additonal path to)
                            // this
                            // node?
                            else if ( calculateAllShortestPaths &&
                                    costComparator.compare( mySeen.get( target ), newCost ) == 0 )
                            {
                                // Put it in predecessors
                                List<Relationship> predList = predecessors.get( target );
                                predList.add( relationship );
                            }
                        }
                    }
                }
            }
            // Check how far we need to continue when searching for all shortest
            // paths
            if ( calculateAllShortestPaths && oneShortestPathHasBeenFound )
            {
                // If we cannot continue or continuation would only find more
                // expensive paths: conclude that all shortest paths have been
                // found.
                allShortestPathsHasBeenFound = queue.isEmpty()
                                               || costComparator.compare(
                                                       mySeen.get( queue.peek() ),
                                                       currentCost ) > 0;
            }
            return currentNode;
        }

        @Override
        public Node next()
        {
            Node currentNode = queue.extractMin();
            CostType currentCost = mySeen.get( currentNode );
            // Already done with this node?
            if ( myDistances.containsKey( currentNode ) )
            {
                return null;
            }
            if ( limitReached() )
            {
                return null;
            }
            ++numberOfNodesTraversed;
            myDistances.put( currentNode, currentCost );
            // TODO: remove from seen or not? probably not... because of path
            // detection
            // Check if we have found a better path
            checkForPath( currentNode, currentCost, otherSeen );
            // Found a path? (abort traversing from this node)
            if ( otherDistances.containsKey( currentNode ) )
            {
                oneShortestPathHasBeenFound = true;
            }
            else
            {
                // Otherwise, follow all edges from this node
                for ( RelationshipType costRelationType : costRelationTypes )
                {
                    ResourceIterable<Relationship> relationships = Iterables.asResourceIterable(
                            currentNode.getRelationships( costRelationType, getDirection() ) );
                    try ( ResourceIterator<Relationship> iterator = relationships.iterator() )
                    {
                        while ( iterator.hasNext() )
                        {
                            Relationship relationship = iterator.next();
                            if ( limitReached() )
                            {
                                break;
                            }
                            ++numberOfTraversedRelationShips;
                            // Target node
                            Node target = relationship.getOtherNode( currentNode );
                            // Find out if an eventual path would go in the opposite
                            // direction of the edge
                            boolean backwardsEdge = relationship.getEndNode().equals( currentNode ) ^ backwards;
                            CostType newCost = costAccumulator.addCosts( currentCost, costEvaluator
                                    .getCost( relationship, backwardsEdge ? Direction.INCOMING : Direction.OUTGOING ) );
                            // Already done with target node?
                            if ( myDistances.containsKey( target ) )
                            {
                                // Have we found a better cost for a node which is
                                // already
                                // calculated?
                                if ( costComparator.compare( myDistances.get( target ), newCost ) > 0 )
                                {
                                    throw new RuntimeException( "Cycle with negative costs found." );
                                }
                                // Equally good path found?
                                else if ( calculateAllShortestPaths &&
                                        costComparator.compare( myDistances.get( target ), newCost ) == 0 )
                                {
                                    // Put it in predecessors
                                    List<Relationship> myPredecessors = predecessors.get( currentNode );
                                    // Dont do it if this relation is already in
                                    // predecessors (other direction)
                                    if ( myPredecessors == null || !myPredecessors.contains( relationship ) )
                                    {
                                        List<Relationship> predList = predecessors.get( target );
                                        if ( predList == null )
                                        {
                                            // This only happens if we get back to
                                            // the
                                            // start node, which is just bogus
                                        }
                                        else
                                        {
                                            predList.add( relationship );
                                        }
                                    }
                                }
                                continue;
                            }
                            // Have we found a better cost for this node?
                            if ( !mySeen.containsKey( target ) ||
                                    costComparator.compare( mySeen.get( target ), newCost ) > 0 )
                            {
                                // Put it in the queue
                                if ( !mySeen.containsKey( target ) )
                                {
                                    queue.insertValue( target, newCost );
                                }
                                // or update the entry. (It is important to keep
                                // these
                                // cases apart to limit the size of the queue)
                                else
                                {
                                    queue.decreaseValue( target, newCost );
                                }
                                // Update it
                                mySeen.put( target, newCost );
                                // Put it in predecessors
                                List<Relationship> predList = new LinkedList<Relationship>();
                                predList.add( relationship );
                                predecessors.put( target, predList );
                            }
                            // Have we found an equal cost for (additonal path to)
                            // this
                            // node?
                            else if ( calculateAllShortestPaths &&
                                    costComparator.compare( mySeen.get( target ), newCost ) == 0 )
                            {
                                // Put it in predecessors
                                List<Relationship> predList = predecessors.get( target );
                                predList.add( relationship );
                            }
                        }
                    }
                }
            }
            // Check how far we need to continue when searching for all shortest
            // paths
            if ( calculateAllShortestPaths && oneShortestPathHasBeenFound )
            {
                // If we cannot continue or continuation would only find more
                // expensive paths: conclude that all shortest paths have been
                // found.
                allShortestPathsHasBeenFound = queue.isEmpty()
                                               || costComparator.compare(
                                                       mySeen.get( queue.peek() ),
                                                       currentCost ) > 0;
            }
            return currentNode;
        }

Replace Generic With Diamond LinkedList<Relationship> with LinkedList<> in method public next() : Node from class org.neo4j.graphalgo.impl.shortestpath.Dijkstra.DijstraIterator


    /**
     * @return One of the shortest paths found or null.
     */
    @Override
    public List<PropertyContainer> getPath()
    {
        if ( startNode == null || endNode == null )
        {
            throw new RuntimeException( "Start or end node undefined." );
        }
        calculate();
        if ( foundPathsMiddleNodes == null || foundPathsMiddleNodes.size() == 0 )
        {
            return null;
        }
        Node middleNode = foundPathsMiddleNodes.iterator().next();
        LinkedList<PropertyContainer> path = new LinkedList<>();
        path.addAll( Util.constructSinglePathToNode( middleNode, predecessors1,
                true, false ) );
        path.addAll( Util.constructSinglePathToNode( middleNode, predecessors2,
                false, true ) );
        return path;
    }

    /**
     * @return One of the shortest paths found or null.
     */
    @Override
    public List<PropertyContainer> getPath()
    {
        if ( startNode == null || endNode == null )
        {
            throw new RuntimeException( "Start or end node undefined." );
        }
        calculate();
        if ( foundPathsMiddleNodes == null || foundPathsMiddleNodes.size() == 0 )
        {
            return null;
        }
        Node middleNode = foundPathsMiddleNodes.iterator().next();
        LinkedList<PropertyContainer> path = new LinkedList<PropertyContainer>();
        path.addAll( Util.constructSinglePathToNode( middleNode, predecessors1,
                true, false ) );
        path.addAll( Util.constructSinglePathToNode( middleNode, predecessors2,
                false, true ) );
        return path;
    }

Replace Generic With Diamond LinkedList<PropertyContainer> with LinkedList<> in method public getPath() : List<PropertyContainer> from class org.neo4j.graphalgo.impl.shortestpath.Dijkstra


    /**
     * @return One of the shortest paths found or null.
     */
    @Override
    public List<Node> getPathAsNodes()
    {
        if ( startNode == null || endNode == null )
        {
            throw new RuntimeException( "Start or end node undefined." );
        }
        calculate();
        if ( foundPathsMiddleNodes == null || foundPathsMiddleNodes.size() == 0 )
        {
            return null;
        }
        Node middleNode = foundPathsMiddleNodes.iterator().next();
        LinkedList<Node> pathNodes = new LinkedList<>();
        pathNodes.addAll( Util.constructSinglePathToNodeAsNodes( middleNode,
                predecessors1, true, false ) );
        pathNodes.addAll( Util.constructSinglePathToNodeAsNodes( middleNode,
                predecessors2, false, true ) );
        return pathNodes;
    }

    /**
     * @return One of the shortest paths found or null.
     */
    @Override
    public List<Node> getPathAsNodes()
    {
        if ( startNode == null || endNode == null )
        {
            throw new RuntimeException( "Start or end node undefined." );
        }
        calculate();
        if ( foundPathsMiddleNodes == null || foundPathsMiddleNodes.size() == 0 )
        {
            return null;
        }
        Node middleNode = foundPathsMiddleNodes.iterator().next();
        LinkedList<Node> pathNodes = new LinkedList<Node>();
        pathNodes.addAll( Util.constructSinglePathToNodeAsNodes( middleNode,
                predecessors1, true, false ) );
        pathNodes.addAll( Util.constructSinglePathToNodeAsNodes( middleNode,
                predecessors2, false, true ) );
        return pathNodes;
    }

Replace Generic With Diamond LinkedList<Node> with LinkedList<> in method public getPathAsNodes() : List<Node> from class org.neo4j.graphalgo.impl.shortestpath.Dijkstra


    /**
     * @return One of the shortest paths found or null.
     */
    @Override
    public List<Relationship> getPathAsRelationships()
    {
        if ( startNode == null || endNode == null )
        {
            throw new RuntimeException( "Start or end node undefined." );
        }
        calculate();
        if ( foundPathsMiddleNodes == null || foundPathsMiddleNodes.size() == 0 )
        {
            return null;
        }
        Node middleNode = foundPathsMiddleNodes.iterator().next();
        List<Relationship> path = new LinkedList<>();
        path.addAll( Util.constructSinglePathToNodeAsRelationships( middleNode,
                predecessors1, false ) );
        path.addAll( Util.constructSinglePathToNodeAsRelationships( middleNode,
                predecessors2, true ) );
        return path;
    }

    /**
     * @return One of the shortest paths found or null.
     */
    @Override
    public List<Relationship> getPathAsRelationships()
    {
        if ( startNode == null || endNode == null )
        {
            throw new RuntimeException( "Start or end node undefined." );
        }
        calculate();
        if ( foundPathsMiddleNodes == null || foundPathsMiddleNodes.size() == 0 )
        {
            return null;
        }
        Node middleNode = foundPathsMiddleNodes.iterator().next();
        List<Relationship> path = new LinkedList<Relationship>();
        path.addAll( Util.constructSinglePathToNodeAsRelationships( middleNode,
                predecessors1, false ) );
        path.addAll( Util.constructSinglePathToNodeAsRelationships( middleNode,
                predecessors2, true ) );
        return path;
    }

Replace Generic With Diamond LinkedList<Relationship> with LinkedList<> in method public getPathAsRelationships() : List<Relationship> from class org.neo4j.graphalgo.impl.shortestpath.Dijkstra


    public DijkstraPriorityQueueImpl( final Comparator<CostType> costComparator )
    {
        super();
        this.costComparator = costComparator;
        queue = new PriorityQueue<>( 11, ( o1, o2 ) -> costComparator.compare( o1.getCost(), o2.getCost() ) );
    }

    public DijkstraPriorityQueueImpl( final Comparator<CostType> costComparator )
    {
        super();
        this.costComparator = costComparator;
        queue = new PriorityQueue<pathObject>( 11, ( o1, o2 ) -> costComparator.compare( o1.getCost(), o2.getCost() ) );
    }

Replace Generic With Diamond PriorityQueue<pathObject> with PriorityQueue<> in method public DijkstraPriorityQueueImpl(costComparator Comparator<CostType>) from class org.neo4j.graphalgo.impl.shortestpath.DijkstraPriorityQueueImpl


    /**
     * This returns the shortest path between two nodes as list of nodes.
     * @param startNode
     *            The start node.
     * @param targetNode
     *            The end node.
     * @return The shortest path as a list of nodes.
     */
    public List<Node> getPath( Node startNode, Node targetNode )
    {
        calculate();
        LinkedList<Node> path = new LinkedList<>();
        int index = nodeIndexes.get( targetNode );
        int startIndex = nodeIndexes.get( startNode );
        Node n = targetNode;
        while ( !n.equals( startNode ) )
        {
            path.addFirst( n );
            index = predecessors[startIndex][index];
            n = IndexedNodes[index];
        }
        path.addFirst( n );
        return path;
    }

    /**
     * This returns the shortest path between two nodes as list of nodes.
     * @param startNode
     *            The start node.
     * @param targetNode
     *            The end node.
     * @return The shortest path as a list of nodes.
     */
    public List<Node> getPath( Node startNode, Node targetNode )
    {
        calculate();
        LinkedList<Node> path = new LinkedList<Node>();
        int index = nodeIndexes.get( targetNode );
        int startIndex = nodeIndexes.get( startNode );
        Node n = targetNode;
        while ( !n.equals( startNode ) )
        {
            path.addFirst( n );
            index = predecessors[startIndex][index];
            n = IndexedNodes[index];
        }
        path.addFirst( n );
        return path;
    }

Replace Generic With Diamond LinkedList<Node> with LinkedList<> in method public getPath(startNode Node, targetNode Node) : List<Node> from class org.neo4j.graphalgo.impl.shortestpath.FloydWarshall


    @Override
    public List<List<PropertyContainer>> getPaths( Node targetNode )
    {
        if ( targetNode == null )
        {
            throw new RuntimeException( "No end node defined" );
        }
        calculateMultiple( targetNode );
        if ( !distances.containsKey( targetNode ) )
        {
            return null;
        }
        return new LinkedList<>( Util.constructAllPathsToNode( targetNode, predecessors1, true, false ) );
    }

    @Override
    public List<List<PropertyContainer>> getPaths( Node targetNode )
    {
        if ( targetNode == null )
        {
            throw new RuntimeException( "No end node defined" );
        }
        calculateMultiple( targetNode );
        if ( !distances.containsKey( targetNode ) )
        {
            return null;
        }
        return new LinkedList<List<PropertyContainer>>( Util
            .constructAllPathsToNode( targetNode, predecessors1, true, false ) );
    }

Replace Generic With Diamond LinkedList<List<PropertyContainer>> with LinkedList<> in method public getPaths(targetNode Node) : List<List<PropertyContainer>> from class org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPathDijkstra


    @Override
    public List<List<Node>> getPathsAsNodes( Node targetNode )
    {
        if ( targetNode == null )
        {
            throw new RuntimeException( "No end node defined" );
        }
        calculateMultiple( targetNode );
        if ( !distances.containsKey( targetNode ) )
        {
            return null;
        }
        return new LinkedList<>( Util.constructAllPathsToNodeAsNodes( targetNode, predecessors1, true, false ) );
    }

    @Override
    public List<List<Node>> getPathsAsNodes( Node targetNode )
    {
        if ( targetNode == null )
        {
            throw new RuntimeException( "No end node defined" );
        }
        calculateMultiple( targetNode );
        if ( !distances.containsKey( targetNode ) )
        {
            return null;
        }
        return new LinkedList<List<Node>>( Util.constructAllPathsToNodeAsNodes(
            targetNode, predecessors1, true, false ) );
    }

Replace Generic With Diamond LinkedList<List<Node>> with LinkedList<> in method public getPathsAsNodes(targetNode Node) : List<List<Node>> from class org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPathDijkstra


    @Override
    public List<List<Relationship>> getPathsAsRelationships( Node targetNode )
    {
        if ( targetNode == null )
        {
            throw new RuntimeException( "No end node defined" );
        }
        calculateMultiple( targetNode );
        if ( !distances.containsKey( targetNode ) )
        {
            return null;
        }
        return new LinkedList<>( Util.constructAllPathsToNodeAsRelationships( targetNode, predecessors1, false ) );
    }

    @Override
    public List<List<Relationship>> getPathsAsRelationships( Node targetNode )
    {
        if ( targetNode == null )
        {
            throw new RuntimeException( "No end node defined" );
        }
        calculateMultiple( targetNode );
        if ( !distances.containsKey( targetNode ) )
        {
            return null;
        }
        return new LinkedList<List<Relationship>>( Util
            .constructAllPathsToNodeAsRelationships( targetNode, predecessors1,
                false ) );
    }

Replace Generic With Diamond LinkedList<List<Relationship>> with LinkedList<> in method public getPathsAsRelationships(targetNode Node) : List<List<Relationship>> from class org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPathDijkstra


    /**
     * @see SingleSourceShortestPath
     */
    @Override
    public List<Node> getPredecessorNodes( Node node )
    {
        List<Node> result = new LinkedList<>();
        List<Relationship> predecessorRelationShips = predecessors1.get( node );
        if ( predecessorRelationShips == null
            || predecessorRelationShips.size() == 0 )
        {
            return null;
        }
        for ( Relationship relationship : predecessorRelationShips )
        {
            result.add( relationship.getOtherNode( node ) );
        }
        return result;
    }

    /**
     * @see SingleSourceShortestPath
     */
    @Override
    public List<Node> getPredecessorNodes( Node node )
    {
        List<Node> result = new LinkedList<Node>();
        List<Relationship> predecessorRelationShips = predecessors1.get( node );
        if ( predecessorRelationShips == null
            || predecessorRelationShips.size() == 0 )
        {
            return null;
        }
        for ( Relationship relationship : predecessorRelationShips )
        {
            result.add( relationship.getOtherNode( node ) );
        }
        return result;
    }

Replace Generic With Diamond LinkedList<Node> with LinkedList<> in method public getPredecessorNodes(node Node) : List<Node> from class org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPathDijkstra


    /**
     * Constructs a path to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return A path as a list of nodes.
     */
    public static List<Node> constructSinglePathToNodeAsNodes( Node node,
        Map<Node,List<Relationship>> predecessors, boolean includeNode,
        boolean backwards )
    {
        List<PropertyContainer> singlePathToNode = constructSinglePathToNode(
            node, predecessors, includeNode, backwards );
        Iterator<PropertyContainer> iterator = singlePathToNode.iterator();
        // When going backwards and not including the node the first element is
        // a relationship. Thus skip it.
        if ( backwards && !includeNode && iterator.hasNext() )
        {
            iterator.next();
        }
        LinkedList<Node> path = new LinkedList<>();
        while ( iterator.hasNext() )
        {
            path.addLast( (Node) iterator.next() );
            if ( iterator.hasNext() )
            {
                iterator.next();
            }
        }
        return path;
    }

    /**
     * Constructs a path to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return A path as a list of nodes.
     */
    public static List<Node> constructSinglePathToNodeAsNodes( Node node,
        Map<Node,List<Relationship>> predecessors, boolean includeNode,
        boolean backwards )
    {
        List<PropertyContainer> singlePathToNode = constructSinglePathToNode(
            node, predecessors, includeNode, backwards );
        Iterator<PropertyContainer> iterator = singlePathToNode.iterator();
        // When going backwards and not including the node the first element is
        // a relationship. Thus skip it.
        if ( backwards && !includeNode && iterator.hasNext() )
        {
            iterator.next();
        }
        LinkedList<Node> path = new LinkedList<Node>();
        while ( iterator.hasNext() )
        {
            path.addLast( (Node) iterator.next() );
            if ( iterator.hasNext() )
            {
                iterator.next();
            }
        }
        return path;
    }

Replace Generic With Diamond LinkedList<Node> with LinkedList<> in method public constructSinglePathToNodeAsNodes(node Node, predecessors Map<Node,List<Relationship>>, includeNode boolean, backwards boolean) : List<Node> from class org.neo4j.graphalgo.impl.shortestpath.Util


    /**
     * Constructs a path to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return A path as a list of relationships.
     */
    public static List<Relationship> constructSinglePathToNodeAsRelationships(
        Node node, Map<Node,List<Relationship>> predecessors, boolean backwards )
    {
        List<PropertyContainer> singlePathToNode = constructSinglePathToNode(
            node, predecessors, true, backwards );
        Iterator<PropertyContainer> iterator = singlePathToNode.iterator();
        // Skip the first, it is a node
        if ( iterator.hasNext() )
        {
            iterator.next();
        }
        LinkedList<Relationship> path = new LinkedList<>();
        while ( iterator.hasNext() )
        {
            path.addLast( (Relationship) iterator.next() );
            if ( iterator.hasNext() )
            {
                iterator.next();
            }
        }
        return path;
    }

    /**
     * Constructs a path to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return A path as a list of relationships.
     */
    public static List<Relationship> constructSinglePathToNodeAsRelationships(
        Node node, Map<Node,List<Relationship>> predecessors, boolean backwards )
    {
        List<PropertyContainer> singlePathToNode = constructSinglePathToNode(
            node, predecessors, true, backwards );
        Iterator<PropertyContainer> iterator = singlePathToNode.iterator();
        // Skip the first, it is a node
        if ( iterator.hasNext() )
        {
            iterator.next();
        }
        LinkedList<Relationship> path = new LinkedList<Relationship>();
        while ( iterator.hasNext() )
        {
            path.addLast( (Relationship) iterator.next() );
            if ( iterator.hasNext() )
            {
                iterator.next();
            }
        }
        return path;
    }

Replace Generic With Diamond LinkedList<Relationship> with LinkedList<> in method public constructSinglePathToNodeAsRelationships(node Node, predecessors Map<Node,List<Relationship>>, backwards boolean) : List<Relationship> from class org.neo4j.graphalgo.impl.shortestpath.Util


    /**
     * Constructs a path to a given node, for a given set of predecessors. The
     * result is a list of alternating Node/Relationship.
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return A path as a list of alternating Node/Relationship.
     */
    public static List<PropertyContainer> constructSinglePathToNode( Node node,
        Map<Node,List<Relationship>> predecessors, boolean includeNode,
        boolean backwards )
    {
        LinkedList<PropertyContainer> path = new LinkedList<>();
        if ( includeNode )
        {
            if ( backwards )
            {
                path.addLast( node );
            }
            else
            {
                path.addFirst( node );
            }
        }
        Node currentNode = node;
        List<Relationship> currentPreds = predecessors.get( currentNode );
        // Traverse predecessors until we have added a node without predecessors
        while ( currentPreds != null && currentPreds.size() != 0 )
        {
            // Get next node
            Relationship currentRelationship = currentPreds.get( 0 );
            currentNode = currentRelationship.getOtherNode( currentNode );
            // Add current
            if ( backwards )
            {
                path.addLast( currentRelationship );
                path.addLast( currentNode );
            }
            else
            {
                path.addFirst( currentRelationship );
                path.addFirst( currentNode );
            }
            // Continue with the next node
            currentPreds = predecessors.get( currentNode );
        }
        return path;
    }

    /**
     * Constructs a path to a given node, for a given set of predecessors. The
     * result is a list of alternating Node/Relationship.
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return A path as a list of alternating Node/Relationship.
     */
    public static List<PropertyContainer> constructSinglePathToNode( Node node,
        Map<Node,List<Relationship>> predecessors, boolean includeNode,
        boolean backwards )
    {
        LinkedList<PropertyContainer> path = new LinkedList<PropertyContainer>();
        if ( includeNode )
        {
            if ( backwards )
            {
                path.addLast( node );
            }
            else
            {
                path.addFirst( node );
            }
        }
        Node currentNode = node;
        List<Relationship> currentPreds = predecessors.get( currentNode );
        // Traverse predecessors until we have added a node without predecessors
        while ( currentPreds != null && currentPreds.size() != 0 )
        {
            // Get next node
            Relationship currentRelationship = currentPreds.get( 0 );
            currentNode = currentRelationship.getOtherNode( currentNode );
            // Add current
            if ( backwards )
            {
                path.addLast( currentRelationship );
                path.addLast( currentNode );
            }
            else
            {
                path.addFirst( currentRelationship );
                path.addFirst( currentNode );
            }
            // Continue with the next node
            currentPreds = predecessors.get( currentNode );
        }
        return path;
    }

Replace Generic With Diamond LinkedList<PropertyContainer> with LinkedList<> in method public constructSinglePathToNode(node Node, predecessors Map<Node,List<Relationship>>, includeNode boolean, backwards boolean) : List<PropertyContainer> from class org.neo4j.graphalgo.impl.shortestpath.Util


    /**
     * Constructs all paths to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return
     */
    public static List<List<Node>> constructAllPathsToNodeAsNodes( Node node,
        Map<Node,List<Relationship>> predecessors, boolean includeNode,
        boolean backwards )
    {
        return new LinkedList<>( constructAllPathsToNodeAsNodeLinkedLists( node, predecessors, includeNode, backwards ) );
    }

    /**
     * Constructs all paths to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return
     */
    public static List<List<Node>> constructAllPathsToNodeAsNodes( Node node,
        Map<Node,List<Relationship>> predecessors, boolean includeNode,
        boolean backwards )
    {
        return new LinkedList<List<Node>>(
            constructAllPathsToNodeAsNodeLinkedLists( node, predecessors,
                includeNode, backwards ) );
    }

Replace Generic With Diamond LinkedList<List<Node>> with LinkedList<> in method public constructAllPathsToNodeAsNodes(node Node, predecessors Map<Node,List<Relationship>>, includeNode boolean, backwards boolean) : List<List<Node>> from class org.neo4j.graphalgo.impl.shortestpath.Util


    /**
     * Constructs all paths to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return List of lists of alternating Node/Relationship.
     */
    public static List<List<PropertyContainer>> constructAllPathsToNode(
        Node node, Map<Node,List<Relationship>> predecessors,
        boolean includeNode, boolean backwards )
    {
        return new LinkedList<>( constructAllPathsToNodeAsLinkedLists( node, predecessors, includeNode, backwards ) );
    }

    /**
     * Constructs all paths to a given node, for a given set of predecessors
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param includeNode
     *            Boolean which determines if the start node should be included
     *            in the paths
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return List of lists of alternating Node/Relationship.
     */
    public static List<List<PropertyContainer>> constructAllPathsToNode(
        Node node, Map<Node,List<Relationship>> predecessors,
        boolean includeNode, boolean backwards )
    {
        return new LinkedList<List<PropertyContainer>>(
            constructAllPathsToNodeAsLinkedLists( node, predecessors,
                includeNode, backwards ) );
    }

Replace Generic With Diamond LinkedList<List<PropertyContainer>> with LinkedList<> in method public constructAllPathsToNode(node Node, predecessors Map<Node,List<Relationship>>, includeNode boolean, backwards boolean) : List<List<PropertyContainer>> from class org.neo4j.graphalgo.impl.shortestpath.Util


    /**
     * Constructs all paths to a given node, for a given set of predecessors.
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return List of lists of relationships.
     */
    public static List<List<Relationship>> constructAllPathsToNodeAsRelationships(
        Node node, Map<Node,List<Relationship>> predecessors, boolean backwards )
    {
        return new LinkedList<>( constructAllPathsToNodeAsRelationshipLinkedLists( node, predecessors, backwards ) );
    }

    /**
     * Constructs all paths to a given node, for a given set of predecessors.
     * @param node
     *            The start node
     * @param predecessors
     *            The predecessors set
     * @param backwards
     *            Boolean, if true the order of the nodes in the paths will be
     *            reversed
     * @return List of lists of relationships.
     */
    public static List<List<Relationship>> constructAllPathsToNodeAsRelationships(
        Node node, Map<Node,List<Relationship>> predecessors, boolean backwards )
    {
        return new LinkedList<List<Relationship>>(
            constructAllPathsToNodeAsRelationshipLinkedLists( node,
                predecessors, backwards ) );
    }

Replace Generic With Diamond LinkedList<List<Relationship>> with LinkedList<> in method public constructAllPathsToNodeAsRelationships(node Node, predecessors Map<Node,List<Relationship>>, backwards boolean) : List<List<Relationship>> from class org.neo4j.graphalgo.impl.shortestpath.Util


    @SuppressWarnings( "unchecked" )
    public static <K, P extends Comparable<P>> PriorityMap<K, K, P> withSelfKeyNaturalOrder(
            boolean reversed, boolean onlyKeepBestPriorities )
    {
        Comparator<P> priority = new NaturalPriority<>( reversed );
        return new PriorityMap<K, K, P>( SELF_KEY, priority, onlyKeepBestPriorities );
    }

    @SuppressWarnings( "unchecked" )
    public static <K, P extends Comparable<P>> PriorityMap<K, K, P> withSelfKeyNaturalOrder(
            boolean reversed, boolean onlyKeepBestPriorities )
    {
        Comparator<P> priority = new NaturalPriority<P>( reversed );
        return new PriorityMap<K, K, P>( SELF_KEY, priority, onlyKeepBestPriorities );
    }

Replace Generic With Diamond NaturalPriority<P> with NaturalPriority<> in method public withSelfKeyNaturalOrder(reversed boolean, onlyKeepBestPriorities boolean) : PriorityMap<K,K,P> from class org.neo4j.graphalgo.impl.util.PriorityMap


    private void putNew( E entity, P priority, K key )
    {
        Node<E, P> node = new Node<>( new Link<>( entity, priority, null ) );
        map.put( key, node );
        queue.add( node );
    }

    private void putNew( E entity, P priority, K key )
    {
        Node<E, P> node = new Node<E, P>( new Link<E,P>( entity, priority, null ) );
        map.put( key, node );
        queue.add( node );
    }

Replace Generic With Diamond Node<E,P> with Node<> in method private putNew(entity E, priority P, key K) : void from class org.neo4j.graphalgo.impl.util.PriorityMap


    public Entry<E, P> peek()
    {
        Node<E, P> node = queue.peek();
        if ( node == null )
        {
            return null;
        }
        return new Entry<>( node );
    }

    public Entry<E, P> peek()
    {
        Node<E, P> node = queue.peek();
        if ( node == null )
        {
            return null;
        }
        return new Entry<E, P>( node );
    }

Replace Generic With Diamond Entry<E,P> with Entry<> in method public peek() : Entry<E,P> from class org.neo4j.graphalgo.impl.util.PriorityMap


    protected static <T> void expect( Iterable<? extends T> items,
            Representation<T> representation, String... expected )
    {
        expect( items, representation, new HashSet<>( Arrays.asList( expected ) ) );
    }

    protected static <T> void expect( Iterable<? extends T> items,
            Representation<T> representation, String... expected )
    {
        expect( items, representation, new HashSet<String>(
                Arrays.asList( expected ) ) );
    }

Replace Generic With Diamond HashSet<String> with HashSet<> in method protected expect(items Iterable<? extends T>, representation Representation<T>, expected String...) : void from class common.AbstractTestBase


    public GraphDescription( String... description )
    {
        List<RelationshipDescription> lines = new ArrayList<>();
        for ( String part : description )
        {
            for ( String line : part.split( "\n" ) )
            {
                lines.add( new RelationshipDescription( line ) );
            }
        }
        this.description = lines.toArray( new RelationshipDescription[lines.size()] );
    }

    public GraphDescription( String... description )
    {
        List<RelationshipDescription> lines = new ArrayList<RelationshipDescription>();
        for ( String part : description )
        {
            for ( String line : part.split( "\n" ) )
            {
                lines.add( new RelationshipDescription( line ) );
            }
        }
        this.description = lines.toArray( new RelationshipDescription[lines.size()] );
    }

Replace Generic With Diamond ArrayList<RelationshipDescription> with ArrayList<> in method public GraphDescription(description String...) from class common.GraphDescription


    @Override
    public Node create( GraphDatabaseService graphdb )
    {
        Map<String, Node> nodes = new HashMap<>();
        Node node = null;
        try ( Transaction tx = graphdb.beginTx() )
        {
            for ( RelationshipDescription rel : description )
            {
                node = rel.create( graphdb, nodes ).getEndNode();
            }
            tx.success();
        }
        return node;
    }

    @Override
    public Node create( GraphDatabaseService graphdb )
    {
        Map<String, Node> nodes = new HashMap<String, Node>();
        Node node = null;
        try ( Transaction tx = graphdb.beginTx() )
        {
            for ( RelationshipDescription rel : description )
            {
                node = rel.create( graphdb, nodes ).getEndNode();
            }
            tx.success();
        }
        return node;
    }

Replace Generic With Diamond HashMap<String,Node> with HashMap<> in method public create(graphdb GraphDatabaseService) : Node from class common.GraphDescription


    protected <E> void assertContains( Iterable<E> actual, E... expected )
    {
        Set<E> expectation = new HashSet<>( Arrays.asList( expected ) );
        for ( E element : actual )
        {
            if ( !expectation.remove( element ) )
            {
                fail( "unexpected element <" + element + ">" );
            }
        }
        if ( !expectation.isEmpty() )
        {
            fail( "the expected elements <" + expectation
                  + "> were not contained" );
        }
    }

    protected <E> void assertContains( Iterable<E> actual, E... expected )
    {
        Set<E> expectation = new HashSet<E>( Arrays.asList( expected ) );
        for ( E element : actual )
        {
            if ( !expectation.remove( element ) )
            {
                fail( "unexpected element <" + element + ">" );
            }
        }
        if ( !expectation.isEmpty() )
        {
            fail( "the expected elements <" + expectation
                  + "> were not contained" );
        }
    }

Replace Generic With Diamond HashSet<E> with HashSet<> in method protected assertContains(actual Iterable<E>, expected E...) : void from class common.Neo4jAlgoTestCase


    public void assertPaths( Iterable<? extends Path> paths, List<String> pathDefs )
    {
        List<String> unexpectedDefs = new ArrayList<>();
        try ( ResourceIterator<? extends Path> iterator = Iterators.asResourceIterator( paths.iterator() ) )
        {
            while ( iterator.hasNext() )
            {
                Path path = iterator.next();

                String pathDef = getPathDef( path );
                int index = pathDefs.indexOf( pathDef );
                if ( index != -1 )
                {
                    pathDefs.remove( index );
                }
                else
                {
                    unexpectedDefs.add( getPathDef( path ) );
                }
            }
        }
        assertTrue( "These unexpected paths were found: " + unexpectedDefs +
                ". In addition these expected paths weren't found:" + pathDefs, unexpectedDefs.isEmpty() );
        assertTrue( "These were expected, but not found: " + pathDefs.toString(), pathDefs.isEmpty() );
    }

    public void assertPaths( Iterable<? extends Path> paths, List<String> pathDefs )
    {
        List<String> unexpectedDefs = new ArrayList<String>();
        try ( ResourceIterator<? extends Path> iterator = Iterators.asResourceIterator( paths.iterator() ) )
        {
            while ( iterator.hasNext() )
            {
                Path path = iterator.next();

                String pathDef = getPathDef( path );
                int index = pathDefs.indexOf( pathDef );
                if ( index != -1 )
                {
                    pathDefs.remove( index );
                }
                else
                {
                    unexpectedDefs.add( getPathDef( path ) );
                }
            }
        }
        assertTrue( "These unexpected paths were found: " + unexpectedDefs +
                ". In addition these expected paths weren't found:" + pathDefs, unexpectedDefs.isEmpty() );
        assertTrue( "These were expected, but not found: " + pathDefs.toString(), pathDefs.isEmpty() );
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public assertPaths(paths Iterable<? extends Path>, pathDefs List<String>) : void from class common.Neo4jAlgoTestCase


    public void assertPaths( Iterable<? extends Path> paths, String... pathDefinitions )
    {
        assertPaths( paths, new ArrayList<>( Arrays.asList( pathDefinitions ) ) );
    }

    public void assertPaths( Iterable<? extends Path> paths, String... pathDefinitions )
    {
        assertPaths( paths, new ArrayList<String>( Arrays.asList( pathDefinitions ) ) );
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public assertPaths(paths Iterable<? extends Path>, pathDefinitions String...) : void from class common.Neo4jAlgoTestCase


    protected SingleSourceShortestPath<Double> getSingleSourceShortestPath()
    {
        return new SingleSourceShortestPathDijkstra<>( 0.0, null, ( relationship, direction ) -> 1.0, new org.neo4j.graphalgo.impl.util.DoubleAdder(),
                new org.neo4j.graphalgo.impl.util.DoubleComparator(), Direction.BOTH, MyRelTypes.R1, MyRelTypes.R2, MyRelTypes.R3 );
    }

    protected SingleSourceShortestPath<Double> getSingleSourceShortestPath()
    {
        return new SingleSourceShortestPathDijkstra<Double>( 0.0, null,
                ( relationship, direction ) -> 1.0, new org.neo4j.graphalgo.impl.util.DoubleAdder(),
            new org.neo4j.graphalgo.impl.util.DoubleComparator(),
            Direction.BOTH, MyRelTypes.R1, MyRelTypes.R2, MyRelTypes.R3 );
    }

Replace Generic With Diamond SingleSourceShortestPathDijkstra<Double> with SingleSourceShortestPathDijkstra<> in method protected getSingleSourceShortestPath() : SingleSourceShortestPath<Double> from class org.neo4j.graphalgo.centrality.BetweennessCentralityTest


    private SingleSourceShortestPath<Double> getSingleSourceShortestPath()
    {
        return new SingleSourceShortestPathDijkstra<>( 0.0, null, ( relationship, direction ) -> 1.0,
                new org.neo4j.graphalgo.impl.util.DoubleAdder(), new org.neo4j.graphalgo.impl.util.DoubleComparator(),
                Direction.BOTH, MyRelTypes.R1 );
    }

    protected SingleSourceShortestPath<Double> getSingleSourceShortestPath()
    {
        return new SingleSourceShortestPathDijkstra<Double>( 0.0, null,
                ( relationship, direction ) -> 1.0, new org.neo4j.graphalgo.impl.util.DoubleAdder(),
            new org.neo4j.graphalgo.impl.util.DoubleComparator(),
            Direction.BOTH, MyRelTypes.R1 );
    }

Replace Generic With Diamond SingleSourceShortestPathDijkstra<Double> with SingleSourceShortestPathDijkstra<> in method private getSingleSourceShortestPath() : SingleSourceShortestPath<Double> from class org.neo4j.graphalgo.centrality.ClosenessCentralityTest


    private ClosenessCentrality<Double> getCentralityAlgorithm()
    {
        return new ClosenessCentrality<>( getSingleSourceShortestPath(), new DoubleAdder(), 0.0, graph.getAllNodes(),
                new CostDivider<Double>()
                {
                    public Double divideByCost( Double d, Double c )
                    {
                        return d / c;
                    }

                    public Double divideCost( Double c, Double d )
                    {
                        return c / d;
                    }
                } );
    }

    ClosenessCentrality<Double> getCentralityAlgorithm()
    {
        return new ClosenessCentrality<Double>( getSingleSourceShortestPath(),
            new DoubleAdder(), 0.0, graph.getAllNodes(),
            new CostDivider<Double>()
            {
                public Double divideByCost( Double d, Double c )
                {
                    return d / c;
                }

                public Double divideCost( Double c, Double d )
                {
                    return c / d;
                }
            } );
    }

Replace Generic With Diamond ClosenessCentrality<Double> with ClosenessCentrality<> in method private getCentralityAlgorithm() : ClosenessCentrality<Double> from class org.neo4j.graphalgo.centrality.ClosenessCentralityTest


    protected SingleSourceShortestPath<Double> getSingleSourceShortestPath()
    {
        return new SingleSourceShortestPathDijkstra<>( 0.0, null, ( relationship, direction ) -> 1.0, new org.neo4j.graphalgo.impl.util.DoubleAdder(),
                new org.neo4j.graphalgo.impl.util.DoubleComparator(), Direction.BOTH, MyRelTypes.R1 );
    }

Replace Generic With Diamond SingleSourceShortestPathDijkstra<Double> with SingleSourceShortestPathDijkstra<> in method protected getSingleSourceShortestPath() : SingleSourceShortestPath<Double> from class org.neo4j.graphalgo.centrality.EccentricityTest


    Eccentricity<Double> getCentralityAlgorithm()
    {
        return new Eccentricity<>( getSingleSourceShortestPath(), 0.0, graph.getAllNodes(), new DoubleComparator() );
    }

    Eccentricity<Double> getCentralityAlgorithm()
    {
        return new Eccentricity<Double>( getSingleSourceShortestPath(), 0.0,
            graph.getAllNodes(), new DoubleComparator() );
    }

Replace Generic With Diamond Eccentricity<Double> with Eccentricity<> in method package getCentralityAlgorithm() : Eccentricity<Double> from class org.neo4j.graphalgo.centrality.EccentricityTest


    /**
     * Same network as above, but with direction BOTH and weights in different
     * directions are given by a map.
     */
    @Test
    public void testWeightAndDirection()
    {
        graph.makeEdgeChain( "a,b" );
        graph.makeEdgeChain( "b,c" );
        graph.makeEdgeChain( "c,d" );
        graph.makeEdgeChain( "c,a" );
        final Map<String,Double> costs = new HashMap<>();
        costs.put( "a,b", 1.0 );
        costs.put( "b,c", 1.0 );
        costs.put( "c,d", 1.0 );
        costs.put( "c,b", 0.1 );
        costs.put( "c,a", 0.1 );
        EigenvectorCentrality eigenvectorCentrality = getEigenvectorCentrality(
            Direction.BOTH, ( relationship, direction ) ->
                {
                    String start = graph
                        .getNodeId( relationship.getStartNode() );
                    String end = graph.getNodeId( relationship.getEndNode() );
                    if ( direction == Direction.INCOMING )
                    {
                        // swap
                        String tmp = end;
                        end = start;
                        start = tmp;
                    }
                    Double value = costs.get( start + "," + end );
                    if ( value == null )
                    {
                        return 0.0;
                    }
                    return value;
                }, graph.getAllNodes(), graph.getAllEdges(), 0.01 );

        assertApproximateCentrality( eigenvectorCentrality, "a", 0.0851, 0.02 );
        assertApproximateCentrality( eigenvectorCentrality, "b", 0.244, 0.02 );
        assertApproximateCentrality( eigenvectorCentrality, "c", 0.456, 0.02 );
        assertApproximateCentrality( eigenvectorCentrality, "d", 0.852, 0.02 );
    }

    /**
     * Same network as above, but with direction BOTH and weights in different
     * directions are given by a map.
     */
    @Test
    public void testWeightAndDirection()
    {
        graph.makeEdgeChain( "a,b" );
        graph.makeEdgeChain( "b,c" );
        graph.makeEdgeChain( "c,d" );
        graph.makeEdgeChain( "c,a" );
        final Map<String,Double> costs = new HashMap<String,Double>();
        costs.put( "a,b", 1.0 );
        costs.put( "b,c", 1.0 );
        costs.put( "c,d", 1.0 );
        costs.put( "c,b", 0.1 );
        costs.put( "c,a", 0.1 );
        EigenvectorCentrality eigenvectorCentrality = getEigenvectorCentrality(
            Direction.BOTH, ( relationship, direction ) ->
                {
                    String start = graph
                        .getNodeId( relationship.getStartNode() );
                    String end = graph.getNodeId( relationship.getEndNode() );
                    if ( direction == Direction.INCOMING )
                    {
                        // swap
                        String tmp = end;
                        end = start;
                        start = tmp;
                    }
                    Double value = costs.get( start + "," + end );
                    if ( value == null )
                    {
                        return 0.0;
                    }
                    return value;
                }, graph.getAllNodes(), graph.getAllEdges(), 0.01 );

        assertApproximateCentrality( eigenvectorCentrality, "a", 0.0851, 0.02 );
        assertApproximateCentrality( eigenvectorCentrality, "b", 0.244, 0.02 );
        assertApproximateCentrality( eigenvectorCentrality, "c", 0.456, 0.02 );
        assertApproximateCentrality( eigenvectorCentrality, "d", 0.852, 0.02 );
    }

Replace Generic With Diamond HashMap<String,Double> with HashMap<> in method public testWeightAndDirection() : void from class org.neo4j.graphalgo.centrality.EigenvectorCentralityTest


    @Test
    public void testBox()
    {
        graph.makeEdgeChain( "a,b,c,d,a" );
        NetworkRadius<Double> radius = new NetworkRadius<>( getSingleSourceShortestPath(), 0.0, graph.getAllNodes(), new DoubleComparator() );
        assertTrue( radius.getCentrality( null ) == 2.0 );
    }

    @Test
    public void testBox()
    {
        graph.makeEdgeChain( "a,b,c,d,a" );
        NetworkRadius<Double> radius = new NetworkRadius<Double>(
            getSingleSourceShortestPath(), 0.0, graph.getAllNodes(),
            new DoubleComparator() );
        assertTrue( radius.getCentrality( null ) == 2.0 );
    }

Replace Generic With Diamond NetworkRadius<Double> with NetworkRadius<> in method public testBox() : void from class org.neo4j.graphalgo.centrality.NetworkRadiusTest


    @Test
    public void testPlusShape()
    {
        graph.makeEdgeChain( "a,b,c" );
        graph.makeEdgeChain( "d,b,e" );
        NetworkRadius<Double> radius = new NetworkRadius<>( getSingleSourceShortestPath(), 0.0, graph.getAllNodes(), new DoubleComparator() );
        assertTrue( radius.getCentrality( null ) == 1.0 );
    }

    @Test
    public void testPlusShape()
    {
        graph.makeEdgeChain( "a,b,c" );
        graph.makeEdgeChain( "d,b,e" );
        NetworkRadius<Double> radius = new NetworkRadius<Double>(
            getSingleSourceShortestPath(), 0.0, graph.getAllNodes(),
            new DoubleComparator() );
        assertTrue( radius.getCentrality( null ) == 1.0 );
    }

Replace Generic With Diamond NetworkRadius<Double> with NetworkRadius<> in method public testPlusShape() : void from class org.neo4j.graphalgo.centrality.NetworkRadiusTest


    @Test
    public void testChain()
    {
        graph.makeEdgeChain( "a,b,c,d,e" );
        NetworkRadius<Double> radius = new NetworkRadius<>( getSingleSourceShortestPath(), 0.0, graph.getAllNodes(), new DoubleComparator() );
        assertTrue( radius.getCentrality( null ) == 2.0 );
    }

    @Test
    public void testChain()
    {
        graph.makeEdgeChain( "a,b,c,d,e" );
        NetworkRadius<Double> radius = new NetworkRadius<Double>(
            getSingleSourceShortestPath(), 0.0, graph.getAllNodes(),
            new DoubleComparator() );
        assertTrue( radius.getCentrality( null ) == 2.0 );
    }

Replace Generic With Diamond NetworkRadius<Double> with NetworkRadius<> in method public testChain() : void from class org.neo4j.graphalgo.centrality.NetworkRadiusTest


    @Test
    public void testPlusShape()
    {
        // Make graph
        graph.makeEdgeChain( "a,b,c" );
        graph.makeEdgeChain( "d,b,e" );
        SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath();
        ParallellCentralityCalculation<Double> pcc =
                new ParallellCentralityCalculation<>( singleSourceShortestPath, graph.getAllNodes() );
        BetweennessCentrality<Double> betweennessCentrality =
                new BetweennessCentrality<>( singleSourceShortestPath, graph.getAllNodes() );
        StressCentrality<Double> stressCentrality = new StressCentrality<>( singleSourceShortestPath, graph.getAllNodes() );
        ClosenessCentrality<Double> closenessCentrality =
                new ClosenessCentrality<>( singleSourceShortestPath, new DoubleAdder(), 0.0, graph.getAllNodes(), new CostDivider<Double>()
                {
                    public Double divideByCost( Double d, Double c )
                    {
                        return d / c;
                    }

                    public Double divideCost( Double c, Double d )
                    {
                        return c / d;
                    }
                } );
        pcc.addCalculation( betweennessCentrality );
        pcc.addCalculation( stressCentrality );
        pcc.addCalculation( closenessCentrality );
        pcc.calculate();

        assertCentrality( betweennessCentrality, "a", 0.0 );
        assertCentrality( betweennessCentrality, "b", 6.0 );
        assertCentrality( betweennessCentrality, "c", 0.0 );
        assertCentrality( betweennessCentrality, "d", 0.0 );
        assertCentrality( betweennessCentrality, "e", 0.0 );
        assertCentrality( stressCentrality, "a", 0.0 );
        assertCentrality( stressCentrality, "b", 6.0 );
        assertCentrality( stressCentrality, "c", 0.0 );
        assertCentrality( stressCentrality, "d", 0.0 );
        assertCentrality( stressCentrality, "e", 0.0 );
        assertCentrality( closenessCentrality, "a", 1.0 / 7 );
        assertCentrality( closenessCentrality, "b", 1.0 / 4 );
        assertCentrality( closenessCentrality, "c", 1.0 / 7 );
        assertCentrality( closenessCentrality, "d", 1.0 / 7 );
        assertCentrality( closenessCentrality, "e", 1.0 / 7 );
    }

    @Test
    public void testPlusShape()
    {
        // Make graph
        graph.makeEdgeChain( "a,b,c" );
        graph.makeEdgeChain( "d,b,e" );
        SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath();
        ParallellCentralityCalculation<Double> pcc = new ParallellCentralityCalculation<Double>(
            singleSourceShortestPath, graph.getAllNodes() );
        BetweennessCentrality<Double> betweennessCentrality = new BetweennessCentrality<Double>(
            singleSourceShortestPath, graph.getAllNodes() );
        StressCentrality<Double> stressCentrality = new StressCentrality<Double>(
            singleSourceShortestPath, graph.getAllNodes() );
        ClosenessCentrality<Double> closenessCentrality = new ClosenessCentrality<Double>(
            singleSourceShortestPath, new DoubleAdder(), 0.0, graph
                .getAllNodes(), new CostDivider<Double>()
            {
                public Double divideByCost( Double d, Double c )
                {
                    return d / c;
                }

                public Double divideCost( Double c, Double d )
                {
                    return c / d;
                }
            } );
        pcc.addCalculation( betweennessCentrality );
        pcc.addCalculation( stressCentrality );
        pcc.addCalculation( closenessCentrality );
        pcc.calculate();

        assertCentrality( betweennessCentrality, "a", 0.0 );
        assertCentrality( betweennessCentrality, "b", 6.0 );
        assertCentrality( betweennessCentrality, "c", 0.0 );
        assertCentrality( betweennessCentrality, "d", 0.0 );
        assertCentrality( betweennessCentrality, "e", 0.0 );
        assertCentrality( stressCentrality, "a", 0.0 );
        assertCentrality( stressCentrality, "b", 6.0 );
        assertCentrality( stressCentrality, "c", 0.0 );
        assertCentrality( stressCentrality, "d", 0.0 );
        assertCentrality( stressCentrality, "e", 0.0 );
        assertCentrality( closenessCentrality, "a", 1.0 / 7 );
        assertCentrality( closenessCentrality, "b", 1.0 / 4 );
        assertCentrality( closenessCentrality, "c", 1.0 / 7 );
        assertCentrality( closenessCentrality, "d", 1.0 / 7 );
        assertCentrality( closenessCentrality, "e", 1.0 / 7 );
    }

Replace Generic With Diamond ClosenessCentrality<Double> with ClosenessCentrality<> in method public testPlusShape() : void from class org.neo4j.graphalgo.centrality.ParallellCentralityCalculationTest


    protected SingleSourceShortestPath<Double> getSingleSourceShortestPath()
    {
        return new SingleSourceShortestPathDijkstra<>( 0.0, null, ( relationship, direction ) -> 1.0, new DoubleAdder(),
                new org.neo4j.graphalgo.impl.util.DoubleComparator(), Direction.BOTH, MyRelTypes.R1 );
    }

Replace Generic With Diamond SingleSourceShortestPathDijkstra<Double> with SingleSourceShortestPathDijkstra<> in method protected getSingleSourceShortestPath() : SingleSourceShortestPath<Double> from class org.neo4j.graphalgo.centrality.StressCentralityTest


    @Test
    public void testBox()
    {
        graph.makeEdgeChain( "a,b,c,d,a" );
        StressCentrality<Double> stressCentrality = new StressCentrality<>( getSingleSourceShortestPath(), graph.getAllNodes() );
        stressCentrality.calculate();
        assertCentrality( stressCentrality, "a", 1.0 );
        assertCentrality( stressCentrality, "b", 1.0 );
        assertCentrality( stressCentrality, "c", 1.0 );
        assertCentrality( stressCentrality, "d", 1.0 );
    }

    @Test
    public void testBox()
    {
        graph.makeEdgeChain( "a,b,c,d,a" );
        StressCentrality<Double> stressCentrality = new StressCentrality<Double>(
            getSingleSourceShortestPath(), graph.getAllNodes() );
        stressCentrality.calculate();
        assertCentrality( stressCentrality, "a", 1.0 );
        assertCentrality( stressCentrality, "b", 1.0 );
        assertCentrality( stressCentrality, "c", 1.0 );
        assertCentrality( stressCentrality, "d", 1.0 );
    }

Replace Generic With Diamond StressCentrality<Double> with StressCentrality<> in method public testBox() : void from class org.neo4j.graphalgo.centrality.StressCentralityTest


    @Test
    public void testPlusShape()
    {
        graph.makeEdgeChain( "a,b,c" );
        graph.makeEdgeChain( "d,b,e" );
        StressCentrality<Double> stressCentrality = new StressCentrality<>( getSingleSourceShortestPath(), graph.getAllNodes() );
        stressCentrality.calculate();
        assertCentrality( stressCentrality, "a", 0.0 );
        assertCentrality( stressCentrality, "b", 6.0 );
        assertCentrality( stressCentrality, "c", 0.0 );
        assertCentrality( stressCentrality, "d", 0.0 );
        assertCentrality( stressCentrality, "e", 0.0 );
    }

    @Test
    public void testPlusShape()
    {
        graph.makeEdgeChain( "a,b,c" );
        graph.makeEdgeChain( "d,b,e" );
        StressCentrality<Double> stressCentrality = new StressCentrality<Double>(
            getSingleSourceShortestPath(), graph.getAllNodes() );
        stressCentrality.calculate();
        assertCentrality( stressCentrality, "a", 0.0 );
        assertCentrality( stressCentrality, "b", 6.0 );
        assertCentrality( stressCentrality, "c", 0.0 );
        assertCentrality( stressCentrality, "d", 0.0 );
        assertCentrality( stressCentrality, "e", 0.0 );
    }

Replace Generic With Diamond StressCentrality<Double> with StressCentrality<> in method public testPlusShape() : void from class org.neo4j.graphalgo.centrality.StressCentralityTest


    @Test
    public void testChain()
    {
        graph.makeEdgeChain( "a,b,c,d,e" );
        StressCentrality<Double> stressCentrality = new StressCentrality<>( getSingleSourceShortestPath(), graph.getAllNodes() );
        stressCentrality.calculate();
        assertCentrality( stressCentrality, "a", 0.0 );
        assertCentrality( stressCentrality, "b", 3.0 );
        assertCentrality( stressCentrality, "c", 4.0 );
        assertCentrality( stressCentrality, "d", 3.0 );
        assertCentrality( stressCentrality, "e", 0.0 );
    }

    @Test
    public void testChain()
    {
        graph.makeEdgeChain( "a,b,c,d,e" );
        StressCentrality<Double> stressCentrality = new StressCentrality<Double>(
            getSingleSourceShortestPath(), graph.getAllNodes() );
        stressCentrality.calculate();
        assertCentrality( stressCentrality, "a", 0.0 );
        assertCentrality( stressCentrality, "b", 3.0 );
        assertCentrality( stressCentrality, "c", 4.0 );
        assertCentrality( stressCentrality, "d", 3.0 );
        assertCentrality( stressCentrality, "e", 0.0 );
    }

Replace Generic With Diamond StressCentrality<Double> with StressCentrality<> in method public testChain() : void from class org.neo4j.graphalgo.centrality.StressCentralityTest


    @Test
    public void canGetMultiplePathsInTriangleGraph() throws Exception
    {
        /* NODE (NAME/INDEX)
         * ==> (two relationships)
         *
         * (A/0) ====== 1 =====> (B/1)
         *   \                    /
         *    - 5 -> (C/2) <- 2 -
         */
        Node nodeA = graph.makeNode( "A" );
        Node nodeB = graph.makeNode( "B" );
        Node nodeC = graph.makeNode( "C" );
        Set<Relationship> expectedFirsts = new HashSet<>();
        expectedFirsts.add( graph.makeEdge( "A", "B", "length", 1d ) );
        expectedFirsts.add( graph.makeEdge( "A", "B", "length", 1 ) );
        Relationship expectedSecond = graph.makeEdge( "B", "C", "length", 2L );
        graph.makeEdge( "A", "C", "length", 5d );

        PathFinder finder = factory.dijkstra( PathExpanders.allTypesAndDirections() );
        Iterator<WeightedPath> paths = finder.findAllPaths( nodeA, nodeC ).iterator();
        for ( int i = 0; i < 2; i++ )
        {
            assertTrue( "expected more paths", paths.hasNext() );
            Path path = paths.next();
            assertPath( path, nodeA, nodeB, nodeC );

            Iterator<Relationship> relationships = path.relationships().iterator();
            assertTrue( "found shorter path than expected",
                    relationships.hasNext() );
            assertTrue( "path contained unexpected relationship",
                    expectedFirsts.remove( relationships.next() ) );
            assertTrue( "found shorter path than expected",
                    relationships.hasNext() );
            assertEquals( expectedSecond, relationships.next() );
            assertFalse( "found longer path than expected",
                    relationships.hasNext() );
        }
        assertFalse( "expected at most two paths", paths.hasNext() );
    }

    @Test
    public void canGetMultiplePathsInTriangleGraph() throws Exception
    {
        /* NODE (NAME/INDEX)
         * ==> (two relationships)
         *
         * (A/0) ====== 1 =====> (B/1)
         *   \                    /
         *    - 5 -> (C/2) <- 2 -
         */
        Node nodeA = graph.makeNode( "A" );
        Node nodeB = graph.makeNode( "B" );
        Node nodeC = graph.makeNode( "C" );
        Set<Relationship> expectedFirsts = new HashSet<Relationship>();
        expectedFirsts.add( graph.makeEdge( "A", "B", "length", 1d ) );
        expectedFirsts.add( graph.makeEdge( "A", "B", "length", 1 ) );
        Relationship expectedSecond = graph.makeEdge( "B", "C", "length", 2L );
        graph.makeEdge( "A", "C", "length", 5d );

        PathFinder finder = factory.dijkstra( PathExpanders.allTypesAndDirections() );
        Iterator<WeightedPath> paths = finder.findAllPaths( nodeA, nodeC ).iterator();
        for ( int i = 0; i < 2; i++ )
        {
            assertTrue( "expected more paths", paths.hasNext() );
            Path path = paths.next();
            assertPath( path, nodeA, nodeB, nodeC );

            Iterator<Relationship> relationships = path.relationships().iterator();
            assertTrue( "found shorter path than expected",
                    relationships.hasNext() );
            assertTrue( "path contained unexpected relationship",
                    expectedFirsts.remove( relationships.next() ) );
            assertTrue( "found shorter path than expected",
                    relationships.hasNext() );
            assertEquals( expectedSecond, relationships.next() );
            assertFalse( "found longer path than expected",
                    relationships.hasNext() );
        }
        assertFalse( "expected at most two paths", paths.hasNext() );
    }

Replace Generic With Diamond HashSet<Relationship> with HashSet<> in method public canGetMultiplePathsInTriangleGraph() : void from class org.neo4j.graphalgo.path.DijkstraTest


    @SuppressWarnings( { "rawtypes", "unchecked" } )
    @Test
    public void canUseBranchState() throws Exception
    {
        // This test doesn't use the predefined finder, which only means an unnecessary instantiation
        // if such an object. And this test will be run twice (once for each finder type in data()).
        /**
         * <pre>
         *   012345    A - B:  2
         *  +------>y  A - B:  2
         * 0|A         B - C:  3
         * 1|          A - C:  10
         * 2| B
         * 3|
         * 4|
         * 5|
         * 6|
         * 7|C
         *  V
         *  x
         *
         * </pre>
         */
        Node nodeA = graph.makeNode( "A", "x", 0d, "y", 0d );
        Node nodeB = graph.makeNode( "B", "x", 2d, "y", 1d );
        Node nodeC = graph.makeNode( "C", "x", 7d, "y", 0d );
        graph.makeEdge( "A", "B", "length", 2d );
        graph.makeEdge( "A", "B", "length", 2d );
        graph.makeEdge( "B", "C", "length", 3d );
        graph.makeEdge( "A", "C", "length", 10d );

        final Map<Node, Double> seenBranchStates = new HashMap<>();
        PathExpander<Double> expander = new PathExpander<Double>()
        {
            @Override
            public Iterable<Relationship> expand( Path path, BranchState<Double> state )
            {
                double newState = state.getState();
                if ( path.length() > 0 )
                {
                    newState += (Double) path.lastRelationship().getProperty( "length" );
                    state.setState( newState );
                }
                seenBranchStates.put( path.endNode(), newState );

                return path.endNode().getRelationships( OUTGOING );
            }

            @Override
            public PathExpander<Double> reverse()
            {
                throw new UnsupportedOperationException();
            }
        };

        double initialStateValue = 0D;
        PathFinder<WeightedPath> traversalFinder = new TraversalAStar( expander,
                new InitialBranchState.State( initialStateValue, initialStateValue ),
                doubleCostEvaluator( "length" ), ESTIMATE_EVALUATOR );
        WeightedPath path = traversalFinder.findSinglePath( nodeA, nodeC );
        assertEquals( (Double) 5.0D, (Double) path.weight() );
        assertPathDef( path, "A", "B", "C" );
        assertEquals( MapUtil.<Node,Double>genericMap( nodeA, 0D, nodeB, 2D ), seenBranchStates );
    }

    @SuppressWarnings( { "rawtypes", "unchecked" } )
    @Test
    public void canUseBranchState() throws Exception
    {
        // This test doesn't use the predefined finder, which only means an unnecessary instantiation
        // if such an object. And this test will be run twice (once for each finder type in data()).
        /**
         * <pre>
         *   012345    A - B:  2
         *  +------>y  A - B:  2
         * 0|A         B - C:  3
         * 1|          A - C:  10
         * 2| B
         * 3|
         * 4|
         * 5|
         * 6|
         * 7|C
         *  V
         *  x
         *
         * </pre>
         */
        Node nodeA = graph.makeNode( "A", "x", 0d, "y", 0d );
        Node nodeB = graph.makeNode( "B", "x", 2d, "y", 1d );
        Node nodeC = graph.makeNode( "C", "x", 7d, "y", 0d );
        graph.makeEdge( "A", "B", "length", 2d );
        graph.makeEdge( "A", "B", "length", 2d );
        graph.makeEdge( "B", "C", "length", 3d );
        graph.makeEdge( "A", "C", "length", 10d );

        final Map<Node, Double> seenBranchStates = new HashMap<Node, Double>();
        PathExpander<Double> expander = new PathExpander<Double>()
        {
            @Override
            public Iterable<Relationship> expand( Path path, BranchState<Double> state )
            {
                double newState = state.getState();
                if ( path.length() > 0 )
                {
                    newState += (Double) path.lastRelationship().getProperty( "length" );
                    state.setState( newState );
                }
                seenBranchStates.put( path.endNode(), newState );

                return path.endNode().getRelationships( OUTGOING );
            }

            @Override
            public PathExpander<Double> reverse()
            {
                throw new UnsupportedOperationException();
            }
        };

        double initialStateValue = 0D;
        PathFinder<WeightedPath> traversalFinder = new TraversalAStar( expander,
                new InitialBranchState.State( initialStateValue, initialStateValue ),
                doubleCostEvaluator( "length" ), ESTIMATE_EVALUATOR );
        WeightedPath path = traversalFinder.findSinglePath( nodeA, nodeC );
        assertEquals( (Double) 5.0D, (Double) path.weight() );
        assertPathDef( path, "A", "B", "C" );
        assertEquals( MapUtil.<Node,Double>genericMap( nodeA, 0D, nodeB, 2D ), seenBranchStates );
    }

Replace Generic With Diamond HashMap<Node,Double> with HashMap<> in method public canUseBranchState() : void from class org.neo4j.graphalgo.path.TestAStar