Confidentiality of the social media data during analysis is a major concern. Several real evidences show how the privacy and security of the data is compromised. One of the essential processes with social media data is to find the shortest paths between selected pair of nodes. This paper proposes a technique to modify the original data before analysis. The algorithm calculates shortest paths (data utility) between target nodes and then classifies edges into partially visited, all-visited and unvisited edges. Each category of edges is then perturbed using a dynamic variable value that is bound to satisfy specific constraints such that the shortest path as well as the shortest paths lengths, between the target node pairs remains the same. This paper proposes an approach to preserve the privacy of the weights and also generates an accurate length of the shortest path. It is also observed that the shortest path lengths between any target pairs of nodes are retained. The output is in the form of graphs, that shows that the proposed perturbation strategy perturbs the sensitive edge weights up to a maximum 72%, while keeping the difference in shortest path lengths minimum (up to 3%). It is hence demonstrated that along with preserving the sensitive information by perturbing the edge weights, the data utility is preserved i.e. the shortest path lengths are kept as near as potential to the original ones.