allShortestPaths()- taking infinite time to get the shortest distance

I am trying to find the shortest distance between 4752 nodes and 1098 relationships using the below query

YIELD sourceNodeId, targetNodeId, distance
WITH sourceNodeId, targetNodeId, distance
WHERE algo.isFinite(distance) = true

MATCH (source:skill{Skill:"java"}) WHERE id(source) = sourceNodeId
MATCH (target:skill) WHERE id(target) = targetNodeId
WITH source, target, distance WHERE source <> target

RETURN source.Skill AS source, target.Skill AS target, distance
ORDER BY distance

All the node and relationship are created using query

LOAD CSV WITH HEADERS FROM "file:///C:/Users/hp/Desktop/relatedSkillSet.csv" AS csvLine



MERGE (s)-[:RELATED_SKILL{re:csvLine.Number_of_associated_posts}]->(r)

I have 3 columns named as Tag, Related_tag and Number_of_associated_posts in my csv

When i run allshortestPaths query as mentioned above it is taking infinite time and i has to force close it.

Is there any another mechanism to achieve this goal or any way to optimise this query to get the result in shortest span as possible ?