As a famous sub-structure of Bayesian network, causal polytree is able to recover the causality very efficiently.
Here, I implement pearl's classical algorithm here for easy using. Details can be seen in Pearl's paper.
To recover general Causal polytree, one can download "Fisher's exact test" in my space for conditional independence test.
One can start from ControlCenter.m, I add a simple example there for better understanding.
If there is any question, just let me know, I will response to you as soon as possible.
 G. Rebane, J. Pearl, The recovery of causal poly-trees from statistical data, in: Proceedings of the Third Conference on Uncertainty Artificial Intelligence, Seattle, Washington, 1987, pp. 222–228
The function " view(biograph( A ))"
demonstrates the matrix A in the form of nice graph. Indeed, you need that toolbox to visually check the result, instead of checking the produced matrix manually.
Your example it relies on a script biograph from Computational Biology tbox....
sorry about it , I have updated it.
IsLeaf function undefined ....
update the file "IsLeaf.m", sorry about my carelessness.
update the graph